|
|
|
@ -31,7 +31,7 @@ nvidia-sim简称NVSMI,提供监控GPU使用情况和更改GPU状态的功能 |
|
|
|
|
|
|
|
|
|
CMD中输入: |
|
|
|
|
|
|
|
|
|
```plant |
|
|
|
|
```text |
|
|
|
|
nvidia-smi |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
@ -114,11 +114,26 @@ with tf.compat.v1.Session(config=config) as sess: |
|
|
|
|
|
|
|
|
|
### 4 指定GPU |
|
|
|
|
|
|
|
|
|
在有多块GPU的服务器上运行tensorflow的时候,如果使用python编程,则可指定GPU,代码如下: |
|
|
|
|
* 在有多块GPU的服务器上运行tensorflow的时候,如果使用python编程,则可指定GPU,代码如下: |
|
|
|
|
|
|
|
|
|
```python |
|
|
|
|
import os |
|
|
|
|
os.environ["CUDA_VISIBLE_DEVICES"] = "2" |
|
|
|
|
|
|
|
|
|
os.environ["CUDA_VISIBLE_DEVICES"]="-1" CPU模式 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
- 另一种方案-给指定的Session分配单独的GPU |
|
|
|
|
|
|
|
|
|
用 tf.device('/gpu:1') 指定Session在第二块GPU上运行。 |
|
|
|
|
tensorflow中不同的GPU使用`/gpu:0`和`/gpu:1`区分, |
|
|
|
|
CPU不区分设备号,表示为`/cpu:0`。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
> 未完待续... |
|
|
|
|