pytorch查看cuda
时间: 2023-07-25 12:09:35 浏览: 145
你可以使用以下代码来查看CUDA是否可用以及当前使用的CUDA版本:
```python
import torch
if torch.cuda.is_available():
device = torch.device("cuda")
print("Current device: ", torch.cuda.get_device_name(0))
print("CUDA Version: ", torch.version.cuda)
else:
print("CUDA is not available")
```
这段代码会打印出当前可用的CUDA设备名称和CUDA版本号。如果CUDA不可用,则会打印出一条消息说明CUDA不可用。
相关问题
pytorch 查看cuda版本
您可以使用以下代码来查看您的 PyTorch 是否支持 CUDA,以及您的 CUDA 版本:
```python
import torch
print(torch.version.cuda) # 打印 CUDA 版本
print(torch.cuda.is_available()) # 检查是否支持 CUDA
```
如果您的 PyTorch 不支持 CUDA,或者您没有安装 CUDA,那么 `torch.cuda.is_available()` 将返回 `False`。
Linux查看pytorch中CUDA
在Linux上查看PyTorch中CUDA的版本,可以使用以下命令:
```
python -c "import torch;print(torch.version.cuda)"
```
这个命令会输出PyTorch中CUDA的版本号。
#### 引用[.reference_title]
- *1* *2* [Linux服务器配置Python+PyTorch+CUDA深度学习环境](https://blog.csdn.net/NSJim/article/details/115386936)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [(A2)查看pytorch、cuda、cudnn版本](https://blog.csdn.net/lwqian102112/article/details/128245895)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)