Hello!
There is a problem that I can’t resolve on my own.
This error pops when I’m saving tensorflow model: TypeError: can’t pickle _thread.RLock objects
I’m using google colab python notebook. Tensorflow is downgraded to 2.3.0 version and added in ADDITIONAL PACKAGES list.
Can’t figure out what am I doing wrong
Welcome to the discussion forums @alieksandr_kim!
Tensorflow and Pickle often don’t play nice.
In this case you can alter your save_model
and load_model
functions to work with the appropriate saving and loading methods.
Also remember to alter the MODEL_OUTPUT_PATH
variable inside the Config
class to be whatever you decide to call your saved model.
If you want to save multiple files please follow the advice on this thread.
Hope that clears things up
Thank you, @alfarzan ! I followed your recommendation and managed to alter save/load functions. They are working fine inside the notebook. Renamed MODEL_OUTPUT_PATH
as well. I saved model as a single .h5 file. However, when I try to submit this very notebook, I get another error.
This is what i get if I use a magic command (%aicrowd_submit) at the end of a notebook:
Preparing to submit…
Collecting the submission code…
Failed to copy model
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
If I download it and try to submit as a file, it fails with a following message:
“Failed to build image with FileFormatError”
Alright, let’s see what is going on. Could you please give me your submission ID?
Here it is. Submission #120639
Ah ok I see what is happening.
So I can see in side your Config
class you have set MODEL_OUTPUT_PATH='/content'
. This should actually just be MODEL_OUTPUT_PATH='<Your model name>.h5'
. Replacing the name with the actual filename.
Then it should work I think
It went through the magic command, but still failed with following message “Failed to build image with DockerBuildError”
Submission #120654
I actually tried different ways. It seems to me that if I use keras saving and loading via h5 format, it won’t go through submission
Ah yes, so this one is all about the package versions. If you go to your submission page and click on the tab that says Evaluation Status
then you will see the following:
You can see that the failure was in the Build Packages And Env
stage. Hence you can click on the logs and at the bottom you will see
Collecting seaborn
Downloading seaborn-0.11.1-py3-none-any.whl (285 kB)
ERROR: Could not find a version that satisfies the requirement shutil (from versions: none)
ERROR: No matching distribution found for shutil
Which tells you that the version you’ve put down for the shutil
package is not found. This is because shutil
is in the standard library and there is no need to install it separately. (Assuming you’re using python 3 which is the only python we support).
So you can just remove that from the package requirements and that should fix the issue