Building wheel for mmcv-full (setup.py) ... error和OSError: CUDA_HOME environment variable is not set

Some problems encountered in the installation and use of mmdetection:

    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'mmcv._ext'

This is the problem of insufficiency caused by installing mmcv instead of mmcv-full. When pip install mmcv-full, there are the following situations:

 Building wheel for mmcv-full (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/xiejun/anaconda3/envs/xiejun/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-c1qginh5
       cwd: /tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/
.
..
...
Failed to build mmcv-full
Installing collected packages: mmcv-full
    Running setup.py install for mmcv-full ... error
    ERROR: Command errored out with exit status 1:
     command: /home/xiejun/anaconda3/envs/xiejun/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-9jhxpj3o/install-record.txt --single-version-externally-managed --compile --install-headers /home/xiejun/anaconda3/envs/xiejun/include/python3.7m/mmcv-full
.
.
.
RuntimeError: Error compiling objects for extension
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/xiejun/anaconda3/envs/xiejun/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5sje9kee/mmcv-full_d11bcf00f28c4d2cab43de59499a7362/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-9jhxpj3o/install-record.txt --single-version-externally-managed --compile --install-headers /home/xiejun/anaconda3/envs/xiejun/include/python3.7m/mmcv-full Check the logs for full command output.

To solve the installation problem of mmcv, you can read this blog, the pro test is effective: https://blog.csdn.net/qq_44442727/article/details/113444207

Another problem encountered is:

OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA.

This is the installation of cuda on the computer, but no environment variables are added, the library cannot find the path during the call, and it cannot be called, and an error is reported. The solution is to add environment variables:

vim ~/.bashrc

Enter the environment variable configuration file:
Insert picture description here
press "E" to edit, add the following content to the end of the text:

export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${
    
    LD_LIBRARY_PATH:+:${
    
    LD_LIBRARY_PATH}}

Then install Esc to change the mode, save, edit and exit, and the command is (:wq) to
exit, then update:

source ~/.bashrc

You can use the following command to verify:

cat /proc/driver/nvidia/version

turn out:

NVRM version: NVIDIA UNIX x86_64 Kernel Module  435.21  Sun Aug 25 08:17:57 CDT 2019
GCC version:  gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 

enter:

nvcc -V

result:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

This can query the information of cuda, and successfully add environment variables.

Guess you like

Origin blog.csdn.net/qq_44442727/article/details/113445640