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

安装和使用mmdetection中遇到的一些问题:

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

这是安装mmcv,而不是安装mmcv-full导致功能不全的问题,pip install mmcv-full时,还有下面这种情况:

 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.

解决mmcv的安装问题,可以看这篇博客,亲测有效:https://blog.csdn.net/qq_44442727/article/details/113444207

还碰到的一个问题是:

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

这个就是在电脑上安装了cuda,但是没有添加环境变量,库在调用的过程中找不到路径,没法调用,就报错了。解决办法就是添加环境变量:

vim ~/.bashrc

进入环境变量配置文件:
在这里插入图片描述
按“E”进行编辑,添加如下内容至文末:

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}}

再安Esc改变模式,保存编辑退出,指令是(:wq)
退出后,进行更新:

source ~/.bashrc

可以使用如下指令进行验证:

cat /proc/driver/nvidia/version

结果是:

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) 

输入:

nvcc -V

结果:

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

这就可以查询到cuda的信息了,成功添加好了环境变量。

猜你喜欢

转载自blog.csdn.net/qq_44442727/article/details/113445640