tensorflow_anaconda安装

简单记录下tensorflow安装过程,以免日后要用。

1.conda  create  --name  tf2.0  python=3.7
切换不同环境:conda activate 环境名字;
以及退出环境:conda deactivate
删除环境:conda env remove --name ENVIRONMENT

pip install torch==1.4.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

验证:
终端输入:python
Python 3.7.13 (default, Mar 29 2022, 02:18:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.zeros(1).cuda()
tensor([0.], device='cuda:0')


2.tensorflow2.0的安装
假设当前已经在 tf2.0 的虚拟环境下,可以直接用 pip 来安装tensorflow2.0:

pip  install  tensorflow==2.0.0  # TensorFlow CPU版本

或者:

pip  install  tensorflow-gpu==2.0.0  # TensorFlow GPU版本,需要具有NVIDIA显卡及正确安装驱动程序

安装速度慢的话可以切换豆瓣源或者清华源:

pip  install  tensorflow-gpu==2.0.0  -i  http://pypi.douban.com/simple/   #或者

pip  install  tensorflow-gpu==2.0.0  -i https://pypi.tuna.tsinghua.edu.cn/simple/

安装之后就可以通过:
在tf2运行环境下进入python

//查看tensorflow 版本
import tensorflow as tf
tf.__version__

tf.test.is_built_with_gpu_support()
等来查看是否正确安装tensorflow。

//查看pytorch版本
进入python交互式环境
import torch
print(torch.__version__) #注意是双下划线

二、cudnn的安装
cudnn的安装比较简单

(1)下载安装文件
按需求下载cudnn的安装文件:https://developer.nvidia.com/rdp/cudnn-archive
(2)安装cudnn
我们从Nvidia官网上下载下来的cudnn for linux的文件格式是.solitairetheme8,想要解压的话需要先转成tgz格式再解压:
cp  cudnn-10.0-linux-x64-v7.3.1.20.solitairetheme8 cudnn-10.0-linux-x64-v7.3.1.20.tgz
tar -xvf cudnn-10.0-linux-x64-v7.3.1.20.tgz

解压下载的文件,可以看到cuda文件夹,在当前目录打开终端,执行如下命令:
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

(3)查看cudnn版本
在终端输入:cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

切换cuda版本
sudo rm -rf cuda
sudo ln -s /usr/local/cuda-9.1 /usr/local/cuda

软件下载记录

python demo_darknet2onnx.py ./model/yolov4.cfg ./model/yolov4.weights ./model/000150.jpg 1
python convertCaffe.py ./model/yolov4_1_3_608_608_static0.onnx ./model/zhang.prototxt ./model/zhang.caffemodel
python convertCaffe.py ./yolov4_1_3_608_608_static.onnx ./zhang.prototxt ./zhang.caffemode
pip install scikit-image
conda create  --name pytorch1.3.1 python=3.6
pip install torch==1.4.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install torchvision==0.4.2 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install onnx==1.6.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install onnxruntime-gpu==1.0.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install tensorflow-gpu==1.15.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install onnx-tf==1.5.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install opencv-python -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install matplotlib -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install tqdm -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install scikit-image -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install protobuf -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install numpy -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install tensorboardX -i https://pypi.douban.com/simple/

pip install open3d --default-timeout=10000 --no-cache-dir --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple/

python darknet2caffe.py ../../yolov3.cfg ../../yolov3.weights zhang.prototxt zhang.caffemodel

export PYTHONPATH=/root/zhangsong/huawei/trainning/caffe/MobileNet-YOLO-master/python:$PYTHONPATH
export PYTHONPATH=/root/zhangsong/huawei/trainning/caffe/MobileNet-YOLO-master/python/caffe:$PYTHONPATH
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值