我正在尝试解开CudaNdarray,我收到导入错误。我知道我需要在一台带有GPU的机器上,所以我四处搜索并找到this BitFusion ec2 instance,据说它有GPU支持以及cuda。我下载了代码的所有依赖项,但我得到了这个:
File "predictor.py", line 112, in <module>
predict = loadModel(filePath = '2_21_dim20000PREDICT113000.save')
File "predictor.py", line 91, in loadModel
model = pickle.load(file2open, encoding='latin1')
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/theano/sandbox/cuda/type.py", line 591, in CudaNdarray_unpickler
raise ImportError("Cuda not found. Cannot unpickle CudaNdarray")
ImportError: Cuda not found. Cannot unpickle CudaNdarray
这是我的代码(Python3):
import os
import sys
import pickle
from random import shuffle
from copy import copy
def loadModel(filePath):
file2open = open(filePath, 'rb')
model = pickle.load(file2open, encoding='latin1')
b.encode("latin1")
file2open.close()
return zlib.decompress(b)
predict = loadModel(filePath = '2_21_dim20000PREDICT113000.save')
答案 0 :(得分:0)
我可以尝试一些事情:
A)确保安装了Cuda工具包:
conda list | grep cudatoolkit
如果您没有看到它,请尝试以下操作:
conda install cudatoolkit
python
>>> from numbapro import cuda
>>> cuda.is_available()
True
>>> cuda.__file__
'/home/ubuntu/anaconda3/envs/snowflakes/lib/python3.5/site-packages/numba/cuda/__init__.py'
B)你是否需要在Theano下导入CUDA包?
python
>>> from theano.sandbox import cuda
>>>cuda.cuda_path
'/home/ubuntu/anaconda3/envs/snowflakes/lib/python3.5/site-packages/theano/sandbox/cuda'