赞
踩
目录
二、在centos环境下安装miniconda-python库(apt-get不能用)
因为是公司提供的电脑不允许访问外网,镜像也只能用公司内部的。写这篇文章是我给像我一样刚毕业的同学们。
适合像我一样的新生,大佬自动跳过。
如有什么问题,请指出,也是我学习的过程~~
nvidia-smi
CUDA_VISIBLE_DEVICES=1 python your_file.py
可以使用如下的形式:
- CUDA_VISIBLE_DEVICES=1 Only device 1 will be seen
- CUDA_VISIBLE_DEVICES=0,1 Devices 0 and 1 will be visible
- CUDA_VISIBLE_DEVICES="0,1" Same as above, quotation marks are optional
- CUDA_VISIBLE_DEVICES=0,2,3 Devices 0, 2, 3 will be visible; device 1 is masked
- CUDA_VISIBLE_DEVICES="" No GPU will be visible
- import os
-
- os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
-
- os.environ["CUDA_VISIBLE_DEVICES"] = "0"
-
- # 设置定量的GPU使用量
-
- config = tf.ConfigProto()
-
- config.gpu_options.per_process_gpu_memory_fraction = 0.9
-
- # 占用GPU90%的显存
-
- session = tf.Session(config=config)
-
- # 设置最小的GPU使用量
-
- config = tf.ConfigProto()
-
- config.gpu_options.allow_growth = True
-
- session = tf.Session(config=config)

miniconda是python管理工具。 在centos 7的linux系统下安装Miniconda
Miniconda — Conda documentation
可以下载miniconda2 也可以下载 miniconda3.建议下载miniconda3 ,这两个的安装方法都一样。
1)如果有网,使用wget
- yum install wget
-
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
2)如果没有权限或没有网络,则离线安装
- bash Miniconda3-latest-Linux-x86_64.sh
-
- #其中Miniconda3-latest-Linux-x86_64.sh为安装包的名字
执行后,输出的结果:
- Welcome to Miniconda3 4.7.10
-
- In order to continue the installation process, please review the license
- agreement.
- Please, press ENTER to continue
- >>>
回车,
-
- Do you accept the license terms? [yes|no]
- [no] >>>
这里默认是 no,但要安装 miniconda 需要输入 yes。
-
- Miniconda3 will now be installed into this location:
- /home/miniconda3
-
- - Press ENTER to confirm the location
- - Press CTRL-C to abort the installation
- - Or specify a different location below
-
- [/home/miniconda3] >>>
输入安装位置,如果回车,则默认安装到/home/miniconda3。
接下来,回车就安装好了。
1)配置pip源
其中镜像源更改成公司的镜像源
先回到用户的主目录:
cd ~
创建.pip目录:
mkdir .pip
在该目录下的pip.conf文件,并向文件中写入指定源:
如果要更换成阿里源:
如果更换成其他源或自己公司的源:
2)配置conda源
同样的操作:
需要在用户目录下创建.condarc文件,然后把相关源的信息写进去:
vi .condarc
若更换成清华源:
若更换成自己公司的,按照同样的方法,将.condarc文件修改为如下内容即可:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。