使用Linux的一些tips(三)

1、看显卡使用情况

  • nvidia-smi
  • 动态:watch -n 0.5 nvidia-smi

2、su进入管理员模式

3、pip的时候各种关卡限制其网速导致网速过慢或安装失败

  • 自己设定安装源
    pip install PIL -i 空格,再加pip源的 url
    例如:pip install PIL -i http://pypi.tuna.tsinghua.edu.cn/simple/
  • 国内pip源的url如下,任选一个:
    阿里云:http://mirrors.aliyun.com/pypi/simple
    豆瓣:http://pypi.douban.com/simple/
    清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
    中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple

4、指定服務器訓練

  • 默认是用显卡0
  • 1.在终端执行程序时指定GPU
    CUDA_VISIBLE_DEVICES=0    python  your_file.py  # 指定GPU集群中第一块GPU使用,其他的屏蔽掉
    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 多GPU一起使用
    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
  • 2.在Python代码中指定GPU
 	import os
    os.environ["CUDA_VISIBLE_DEVICES"] = "0"   #指定第一块gpu 
  • 3.设置定量的GPU使用量
 	config = tf.ConfigProto() 
    config.gpu_options.per_process_gpu_memory_fraction = 0.9 # 占用GPU90%的显存 
    session = tf.Session(config=config)
  • 4.设置最小的GPU使用量
	config = tf.ConfigProto() 
    config.gpu_options.allow_growth = True 
    session = tf.Session(config=config)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值