我已经看过一些关于这个问题的帖子(1,2),但没有一个帖子对我来说很重要。我正在尝试将nvidia-ml-py
版本7.352.0安装到我的Anaconda Python 2.7环境中。
基于Link2上面我看到的唯一合适的方法只是python setup.py install
,setup.py
的输出如下
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying pynvml.py -> build/lib.linux-x86_64-2.7
copying nvidia_smi.py -> build/lib.linux-x86_64-2.7
running install_lib
copying build/lib.linux-x86_64-2.7/nvidia_smi.py -> /usr/local/lib/python2.7/dist-packages
copying build/lib.linux-x86_64-2.7/pynvml.py -> /usr/local/lib/python2.7/dist-packages
byte-compiling /usr/local/lib/python2.7/dist-packages/nvidia_smi.py to nvidia_smi.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/pynvml.py to pynvml.pyc
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/nvidia_ml_py-7.352.0.egg-info
据我所知,这并没有安装Anaconda可以看到它的模块。但奇怪的是,如果我从我的py27
Anaconda源打开Python REPL,我可以成功导入和使用该库。
Python 2.7.14 |Anaconda, Inc.| (default, Dec 7 2017, 17:05:42)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pynvml
>>> from pynvml import *
>>> nvmlInit()
>>> print "Driver Version:", nvmlSystemGetDriverVersion()
Driver Version: 384.98
>>> nvmlDeviceGetCount()
1L
虽然在Python文件中导入库时,Anaconda / Python无法找到该模块。
Traceback (most recent call last):
File "PyNVML_Test0.py", line 4, in <module>
from pynvml import *
ImportError: No module named pynvml
如何才能正确安装此模块,以便我的Anaconda Python 2.7源可以看到它?
EDIT1:啊,我在REPL中使用库的唯一原因是因为我从库的目录中启动了REPL ..