ModuleNotFoundError: No module named ‘pycuda._driver‘ python3.7

#bug
ModuleNotFoundError: No module named 'pycuda._driver'

原因是系统同时安装了python3.7和python3.8, 当python3.8为默认的python3时,安装pycuda是对于python3.8版本

import pycuda.autoinit
import pycuda.driver as cuda

就会报标题的错误.

卸载python3.8(tensorrt7.0.0只支持到python3.7)

sudo apt-get remove python3.8
sudo apt-get remove --auto-remove python3.8
sudo apt-get purge python3.8

rm -rf /usr/bin/python3
# 将python3链接到python3.7
ln -s /usr/bin/python3.7 /usr/bin/python3

# 重新安装pycuda
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycuda --no-binary :all:

你可能感兴趣的:(TensorRT)