参考:
1.先激活虚拟环境
conda activate yolov7_wxf
2.进入该环境中
$ python
Python 3.8.0 (default, Nov 6 2019, 21:49:08)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
1.8.1
// 查看GPU 能否使用
>>> torch.cuda.is_available()
True
// 查看显卡的数量
>>> print(torch.cuda.device_count())
2
// 查看显卡的系列
>>> print(torch.cuda.get_device_name(0))
Tesla T4
>>> print(torch.cuda.current_device())
0
# 查看GPU的容量
>>> torch.cuda.get_device_capability(device=0)
(7, 5)
// 查看当前cuda流
>>> torch.cuda.current_stream(device=0)
<torch.cuda.Stream device=cuda:0 cuda_stream=0x0>
// 查看显卡的属性
>>> print(torch.cuda.get_device_properties(0))
_CudaDeviceProperties(name='Tesla T4', major=7, minor=5, total_memory=15109MB, multi_processor_count=40)
>>> num = torch.cuda.device_count()
>>> infos = [torch.cuda.get_device_properties(i) for i in range(num)]
>>> print(infos)
[_CudaDeviceProperties(name='Tesla T4', major=7, minor=5, total_memory=15109MB, multi_processor_count=40),
_CudaDeviceProperties(name='Tesla T4', major=7, minor=5, total_memory=15109MB, multi_processor_count=40)]