我已经在Windows 8上安装了Anaconda,之后使用PyTorch完成了安装。 但是在导入火炬时会出错。
进口火炬
AttributeError Traceback (most recent
call last)
<ipython-input-4-eb42ca6e4af3> in <module>
----> 1 import torch
I:\ProgramData\Anaconda3\lib\site-packages\torch\__init__.py in
<module>
51 from ctypes.wintypes import DWORD, HMODULE
52
---> 53 AddDllDirectory = windll.kernel32.AddDllDirectory
54 AddDllDirectory.restype = DWORD
55 AddDllDirectory.argtypes = [c_wchar_p]
I:\ProgramData\Anaconda3\lib\ctypes\__init__.py in __getattr__(self,
name)
367 if name.startswith('__') and name.endswith('__'):
368 raise AttributeError(name)
--> 369 func = self.__getitem__(name)
370 setattr(self, name, func)
371 return func
I:\ProgramData\Anaconda3\lib\ctypes\__init__.py in __getitem__(self,
name_or_ordinal)
372
373 def __getitem__(self, name_or_ordinal):
--> 374 func = self._FuncPtr((name_or_ordinal, self))
375 if not isinstance(name_or_ordinal, int):
376 func.__name__ = name_or_ordinal
AttributeError: function 'AddDllDirectory' not found
另外,当我使用以下命令时,它也显示了pytorch Anaconda命令提示符。
(base) C:\Users\rk88>conda list pytorch
# packages in environment at I:\ProgramData\Anaconda3:
#
# Name Version Build Channel
pytorch 1.0.1 py3.7_cuda100_cudnn7_1
PyTorch
如果您之前遇到过此问题,任何人都可以帮助我解决该问题。
谢谢
答案 0 :(得分:0)
在anaconda提示中尝试以下内容
conda create -n <env_name>python=3.6
conda activate <env_name>
conda install pytorch-cpu torchvision-cpu -c pytorch
如果您使用的是GPU
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch