1. torch installed in conda virtual environment
The normal commands work fine, but using the cuda command.is_available()
then False is output.
2. After a review of the information
The root cause of the problem isMismatch between CUDA environment and Torch versionThe most straightforward solution, therefore, is to use the officially recommended version for adaptation.
3. Ideas for solutions
To check the version of cuda installed on this machine, there are three commands to look through
cat /usr/local/cuda/ nvidia-smi nvcc -V
Sometimes it's unfortunate to output three different versions, here in a virtual environment it must be output asnvcc -V
The version looked up is the main one used as CUDA version information. For example, my version is 10.1
Check the official website for the corresponding installation commands, and then replace the existing version as follows
/
Find your CUDA version 10.1.
Installation in a virtual environment
Done, start testing
4. Other solution ideas
Some people may just cudatoolkit version can not be right, if you are lucky, only for cudatoolkit version matching can be completed, and the installation speed is also very fast installation commands, remember to add the Tsinghua source, otherwise turtle speed.
cudatoolkit=9.0 means you need the corresponding version.
conda install cudatoolkit=9.0 -c /anaconda/pkgs/free/linux-64/
5. Summary
Two solutions to the .is_available() result of false are provided
- The first method is a million dollar method is more recommended, but the installation speed is rather touching
- The second method is an accurate fix, but you need to check the corresponding version yourself
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.