I have a model that runs successfully on jetson AGX (pytorch 1.6), but it gets an error on jetson orin(pytorch 1.11):
736 restore_location = _get_restore_location(map_location)
--> 738 class UnpicklerWrapper(pickle_module.Unpickler): # type: ignore[name-defined]
740 def find_class(self, mod_name, name):
741 if type(name) is str and 'Storage' in name:
TypeError: the first argument must be callable
I read the internet saying the solution is to downgrade pytorch
I followed the tutorial to compile pytorch and it gives the following error
[ 81%] Building NVCC (Device) object caffe2/CMakeFiles/torch_cuda.dir/operators/torch_cuda_generated_depthwise_3x3_conv_op_cudnn.cu.o /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(149): warning: the “visibility” attribute can only appear on functions and variables with external linkage /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(200): warning: the “visibility” attribute can only appear on functions and variables with external linkage /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(236): warning: the “visibility” attribute can only appear on functions and variables with external linkage /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(908): error: namespace “thrust” has no member “host_vector” /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(908): error: expected an expression /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(909): error: namespace “thrust” has no member “host_vector” /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(909): error: expected an expression /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(910): error: namespace “thrust” has no member “host_vector” /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(910): error: type name is not allowed /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(910): error: expected an expression /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(912): error: identifier “A_array” is undefined /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(913): error: identifier “B_array” is undefined /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(914): error: identifier “C_array” is undefined /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(917): error: identifier “A_array” is undefined /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(919): error: identifier “B_array” is undefined /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(920): error: identifier “C_array” is undefined /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(1763): warning: the “visibility” attribute can only appear on functions and variables with external linkage /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(2234): warning: the “visibility” attribute can only appear on functions and variables with external linkage /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(2282): warning: the “visibility” attribute can only appear on functions and variables with external linkage /home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu(2846): warning: the “visibility” attribute can only appear on functions and variables with external linkage 13 errors detected in the compilation of “/home/py/Downloads/pytorch/caffe2/utils/math_gpu.cu”. CMake Error at torch_cuda_generated_math_gpu.cu.o.Release.cmake:281 (message): Error generating file /home/py/Downloads/pytorch/build/caffe2/CMakeFiles/torch_cuda.dir/utils/./torch_cuda_generated_math_gpu.cu.o make[2]: *** [caffe2/CMakeFiles/torch_cuda.dir/build.make:1388: caffe2/CMakeFiles/torch_cuda.dir/utils/torch_cuda_generated_math_gpu.cu.o] Error 1 make[2]: *** Waiting for unfinished jobs… make[1]: *** [CMakeFiles/Makefile2:6966: caffe2/CMakeFiles/torch_cuda.dir/all] Error 2 make: *** [Makefile:141: all] Error 2
Hi @Raymond_456, unfortunately it would seem from your attempt to build this older version of PyTorch for JetPack 5.0, there were some updates required in PyTorch needed to support CUDA 11.4:
So this pickling/unpickling error you get seems to be related to loading/saving the model that came from an older version of PyTorch. It may be worth trying to install a newer version on your Xavier device (or PC) and seeing you can re-save or export it so that the model gets updated.
Means that I need to retrain once on the new pytorch version? Because I try to load the model weights with the new pytorch version, I get an error: “TypeError: the first argument must be callable”
If you aren’t already, can you try using torch’s load_state_dict() function for restoring the model weights?
Aside from the fact of not being able to build older PyTorch versions on JetPack 5.0 due to newer CUDA requirements, this issue you are having of not being able to load older PyTorch checkpoints on newer versions of PyTorch doesn’t seem specific to Jetson - so you might want to try asking on the PyTorch discourse forums on PyTorch github about it.