ubuntu16.04 +tensorflow1.4安装 + 运行问题解决
来源:互联网 发布:云烟 淘宝客 编辑:程序博客网 时间:2024/05/16 18:16
ubuntu16.04 +tensorflow1.4安装
1、下载anaconda最新版,并安装:
bash Anaconda3-5.0.1-Linux-x86_64.sh安装完成后输入:source ~/.bashrc.环境配置生效。
2、安装tensorflow环境以及tensorflow软件
conda create -n tensorflow python=3.5
source activate tensorflow
pip install --ignore-installed --upgrade \
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp35-cp35m-linux_x86_64.whl
注意:
@国内无法访问https://storage.googleapis.com/,去github上找对应的下载代替掉。但不知道为什么,安装完成后没有tensorboard功能。
@找国内清华镜像:https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/
@这里如果python版本和tensorflow-1.4.0-cp35-cp35m-linux_x86_64.whl的版本不一致,安装时会出现*.whl is not supported wheel on this platform的错误提升信息。
3、运行:
source activate tensorflow
否则import tensorflow时会提示找不到。
sudo ldconfig /usr/local/cuda/lib64
或者
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
否则会提示libcublas.so.8.0:cannot open shared object file:No such file or directory
4、电脑重启后无法进入source
~/.bashrc中添加:
exprot PATH=/home/chenxi/Anaconda/bin:$PATH
tensorflow问题:
问题一、报错 failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICE
tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x3f287f0 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
原因是在创建session时没有使用我想让它用的gpu,所以需要设置CUDA_VISIBLE_DEVICES
方法1 在python程序中
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
方法2
运行时
CUDA_VISIBLE_DEVICES=1 python **.py
方法3
直接在环境变量中 export
问题二、CUDA_ERROE_OUT_OF_MEMORY
E tensorflow/stream_executor/cuda/cuda_driver.cc:924] failed to alloc 17179869184 bytes on host: CUDA_ERROR_OUT_OF_MEMORY
W ./tensorflow/core/common_runtime/gpu/pool_allocator.h:195] could not allocate pinned host memory of size: 17179869184
Killed
是 服务器的GPU大小为M,tensorflow只能申请N(N<M),也就是tensorflow告诉你 不能申请到GPU的全部资源 然后就不干了。
解决方法:
找到代码中Session
在session定义前 增加
config = tf.ConfigProto(allow_soft_placement=True)
#最多占gpu资源的70%
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
#开始不会给tensorflow全部gpu资源 而是按需增加
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
这样就没问题了
问题三、训练中,GPU占用率低。
目前无解,ubuntu下能全速运行。
- ubuntu16.04 +tensorflow1.4安装 + 运行问题解决
- ubuntu16.04 安装tensorflow1.4
- ubuntu16.04安装tensorflow1.3
- Ubuntu16.04+tensorflow1.2+anaconda2安装配置
- ubuntu16.4快速 安装tensorflow1.1.0
- Ubuntu16.04+Nvidia GTX 1080+CUDA9.0+cuDNN7+Tensorflow1.4+Anaconda安装
- ubuntu16.04安装cuda8.0+cuDNN6.0+tensorflow1.4配置过程
- ubuntu16.04:cuda8.0+python3.5+tensorflow1.4+opencv3.2安装说明
- Ubuntu16.04安装gpu版tensorflow1.2+cuda+cudnn
- Ubuntu16.04 python3.5下安装pip3与TensorFlow1.0.0
- Ubuntu16.04安装tensorflow(Anaconda3+pycharm2017+tensorflow1.3.0+CPU)
- ubuntu16.04安装cuda8.0和tensorflow1.3
- Ubuntu16.04 配置tensorflow1.0 gpu版本
- Ubuntu16.04 配置tensorflow1.0 gpu版本
- 初用Linux, 安装Ubuntu16.04+NVIDIA387+CUDA8.0+cudnn5.1+TensorFlow1.0.1
- ubuntu16.04下tensorflow1.0+CUDA8.0+cudnn8.0安装配置
- 从零开始安装TensorFlow1.0+keras(Ubuntu16.04+CUDA8.0+Cudnn5.1+TITANX)
- ubuntu16.04LTS安装tensorflow1.1.0(pip方式/python2.7版本/cpu版本)
- SQL Server 触发器
- Android Studio 打包多个APK对应不同API
- Python下修改pip安装源
- IntelliJ IDEA 使用
- Liunx 开机自启管理
- ubuntu16.04 +tensorflow1.4安装 + 运行问题解决
- jvm一问一答
- java
- CSS学习
- php curl_multi批量发送http请求
- mysql导入过大.sql文件报错处理
- 标准BT.656并行数据结构
- Linux/Centos 安装Redis遇到问题及解决
- C字符串操作总结