According to the pytorch document, when loading the model, you can specify to load the tensor of the model to a specific target GPU
the loading methods are:
>>> torch.load('tensors.pt')
# 1. Load all tensors onto the GPU 0
>>> torch.load('tensors.pt', map_location=torch.device('cuda:0'))
# 2. Load all tensors onto GPU 1
>>> torch.load('tensors.pt', map_location=lambda storage, loc: storage.cuda(1))
# 3. Map tensors from GPU 1 to GPU 0
>>> torch.load('tensors.pt', map_location={'cuda:1':'cuda:0'})
The actual measurement shows that
method 1 is not loaded into the target card at all. The original card on which the model was trained is still loaded into the original old card number, so the assignment fails
in method 3, errors are reported between codes. Location. Startswitch (‘cuda ‘): attributeerror:’ nonetype ‘object has no attribute’ startswitch ‘. After analyzing the code, it is found that this is a bug of torch itself! Pit father
method 2: normally load the tensors on cuda1.
Read More:
- Pytorch failed to specify GPU resolution
- [Solved] Pytorch3d Error: RuntimeError: Not compiled with GPU support.
- [Solved] pytorch Load Error: “RuntimeError: Error(s) in loading state_dict for Sequential:”
- Opencv Can not Find opencv2/gpu/gpu.hpp [How to Solve]
- [Solved] RuntimeError: Error(s) in loading state_dict for Model: Missing key(s) in state_dict
- How to Solve error: command ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe‘ failed
- Internalerror: GPU sync failed error (How to Solve)
- [Solved] ORA-21525: attribute number or (collection element at index) string violated its constraints
- [Solved] NCCL error in: /pytorch/torch/lib/c10d/ProcessGroupNCCL ,unhandled cuda error, NCCLversion 2.7.8
- Onnx to tensorrt model error [How to Solve]
- Tensorflow GPU error (4 Type Error and their Solutions)
- Error 1 error MSB3721: Command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe” -genco
- error while loading shared libraries: lib*.so: cannot open shared object file: No such file or directory
- Error:scalac: missing or invalid dependency detected while loading class file ***
- [Samtools] Run error: error while loading shared libraries: libcrypto.so.1.0.0 or libncurses.so.5 or libtinfow.so.5
- Vitis-AI Generate a Quantitative Model: NotImplementedError
- [Solved] Instantiation of ‘sdram_model_plus‘ failed. The design unit was not found.
- Keras’ print model error: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
- TensorRT model quantization error: Error Code 1: Cuda Runtime (an illegal memory access was encountered)