tensorflow使用常见问题

问题一、
参考链接:
https://stackoverflow.com/questions/41890549/tensorflow-cannot-open-libcuda-so-1

报错log如下:

I tensorflow/stream_executor/dso_loader.cc:105] Couldn't open CUDA library libcuda.so.1. LD_LIBRARY_PATH: /home/yaoming/pycharm-community/bin:
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:160] hostname: yaoming-ThinkPad-T470p
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:185] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] kernel reported version is: Permission denied: could not open driver version path for reading: /proc/driver/nvidia/version
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1080] LD_LIBRARY_PATH: /home/yaoming/pycharm-community/bin:
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1081] failed to find libcuda.so on this system: Failed precondition: could not dlopen DSO: libcuda.so.1; dlerror: libnvidia-fatbinaryloader.so.375.39: cannot open shared object file: No such file or directory

解决方法:

bcuda.so.1 is a symlink to a file that is specific to the version of your NVIDIA drivers. It may be pointing to the wrong version or it may not exi# See where the link is pointing.
ls /usr/lib/x86_64-linux-gnu/libcuda.so.1 -la

My result:

lrwxrwxrwx 1 root root 19 Feb 22 20:40 \
/usr/lib/x86_64-linux-gnu/libcuda.so.1 -> ./libcuda.so.375.39

Make sure it is pointing to the right version.
Compare it with the installed NVIDIA driver.
nvidia-smi

Replace libcuda.so.1 with a link to the correct version/usr/lib/x86_64-linux-gnu
sudo ln -f -s libcuda.so.

Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH: 
I tensorflow/stream_executor/cuda/cuda_dnn.cc:3448] Unable to load cuDNN DSO
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
X_train shape: (60000, 28, 28, 1)
60000 train samples

解决方法:
1、

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

2、
You can also add these commands to the end of your ~/.bashrc so they get executed next time you login.

3、确保已经做过以下操作

First of all, please make sure that you have already installed cudnn. The installation should be done separately after the installation of Cuda.

Then you need to find your path of 'libcudnn.so.' by:
    sudo find /usr/ -name 'libcudnn.so'

For me, I got /usr/local/cuda-8.0/targets/x86_64-linux/lib.

You need also find your path where the libraries could be found by using the well-loaded library such as libcufft.so
  sudo find /usr/ -name 'libcufft.so'
For me, I got /usr/lib.

Now copy the files to right place:
    sudo cp /usr/local/cuda-8.0/targets/x86_64-linux/lib/libcud* /usr/lib
Quit the previous Tensorflow session and start a new one et to test. It works for me :)

问题三:

SyntaxError: Non-ASCII character '\xe5

解决方法:
Python默认编码错误SyntaxError: Non-ASCII character ‘\xe5’之解决方法
在编写Python时,当使用中文输出或注释时运行脚本,会提示错误信息:
SyntaxError: Non-ASCII character ‘\xe5’ in file *

解决方法:
python的默认编码文件是用的ASCII码,你将文件存成了UTF-8!!!(文件中存在中文或者其他语言,就会出现此问题!)
解决办法很简单!!!
在文件开头加入:

# -*- coding: UTF-8 -*-    
或者  #coding=utf-8

(注:此语句一定要添加在源代码的第一行)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值