When running yolov5, run the script after installing pytorch
import torch
a=torch.cuda.is_available()
print(torch.__version__)
print(a)
An error occurred:
UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment,
e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero.
(Triggered internally at /opt/conda/conda-bld/pytorch_1623448255797/work/c10/cuda/CUDAFunctions.cpp:115.)
return torch._C._cuda_getDeviceCount() > 0
First, check whether the versions of the graphics card driver, CUDA, cudnn and pytorch match. If not, uninstall and reinstall the corresponding version.
CUDA10.2 Python3.8 pytorch1.8 no mistake.
If the versions are correct, you need to set the environment variable and enter sudo vim ~/.bashrc
, add at the end:
# The first three lines are required when installing CUDA
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda/bin
export CUDA_VISIBLE_DEVICES=0
Save and exit. Try whether you can use CUDA.
If not, enter apt-get install NVIDIA-modprobe
, and there should be no problem.
It will be OK when you installed apt-get install NVIDIA-modprobe
Read More:
- [Solved] UserWarning: CUDA initialization: CUDA unknown error
- Cuda Runtime error (38) : no CUDA-capable device is detected
- TensorFlow-gpu Error: failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
- [Solved] RuntimeError: CUDA error: out of memory
- CUDA_ERROR_SYSTEM_DRIVER_MISMATCH [How to Solve]
- PyCharm Error: RuntimeError: CUDA out of memory [How to Solve]
- [Solved] RuntimeError: CUDA error: invalid device ordinal
- [Solved] NCCL error in: /pytorch/torch/lib/c10d/ProcessGroupNCCL ,unhandled cuda error, NCCLversion 2.7.8
- [Solved] CUDA fails to compile in visual studio and throws error msb3721 and nvcc fatal
- [Solved] Runtimeerror: CUDA error: device side assert triggered
- CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling `cublasCreate(handle)`
- [Solved] RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
- [Solved] matlab Error: CUDA_ERROR_SYSTEM_NOT_READY
- How to Solve error: command ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe‘ failed
- Deep learning model error + 1: CUDA error: device side assert triggered
- [Solved] torch Do Targer Detection Error: RuntimeError: CUDA error: device-side assert triggered
- [Solved] CUDA error: device side assert triggered classification task error
- Error 1 error MSB3721: Command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe” -genco
- TensorRT model quantization error: Error Code 1: Cuda Runtime (an illegal memory access was encountered)
- Tensorflow Error polling for event status: failed to query event: CUDA_ERROR_ILLEGAL_ADDRESS