ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

这是在python中使用caffe产生的错误.

程序很普通:

#-*-coding=utf-8-*-

import numpy as np
import matplotlib.pyplot as plt

# Load caffe
import sys
caffe_root = "~/Documents/caffe-master/"
sys.path.insert(0, caffe_root + 'python')
import caffe

import os

caffe.set_device(0)
caffe.set_mode_gpu()
model_weights = "test1_iter_240000.caffemodel"
model_def = "test.prototxt"

net = caffe.Net(model_def, model_weights, caffe.TEST)
image = caffe.io.load_image("1.jpg")
print(net.blobs['data'].data.shape)

参考网址:https://github.com/tensorflow/tensorflow/issues/5343

locate libcudart.so.8.0
/usr/local/cuda-8.0/lib64/libcudart.so.8.0
/usr/local/cuda-8.0/lib64/libcudart.so.8.0.61


我的机子上,LD_LIBRARY_PATH已经包含了/usr/local/cuda-8.0/lib64
解决方法:sudo ldconfig /usr/local/cuda/lib64


ldconfig命令的用途主要是在默认搜寻目录/lib/usr/lib以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态链接库(格式如lib*.so*),进而创建出动态装入程序(ld.so)所需的连接和缓存文件。缓存文件默认为/etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表,为了让动态链接库为系统所共享,需运行动态链接库的管理命令ldconfig,此执行程序存放在/sbin目录下。

ldconfig通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。

猜你喜欢

转载自www.cnblogs.com/benbencoding798/p/9052980.html