簡體   English   中英

CUDA 錯誤:使用 python 3.9 時設備序號無效

[英]CUDA error: invalid device ordinal when using python 3.9

我正在嘗試執行代碼,但在編譯這段代碼時我不斷收到此錯誤:

  import tensorflow as tf

  from xba import XBA

  import torch

  torch.tensor([1, 2, 3, 4]).to(device="cuda:2")

torch.tensor([1, 2, 3, 4]).to(device="cuda:2") 生成此錯誤:“

RuntimeError: CUDA error: invalid device ordinal
CUDA kernel errors might be asynchronously reported at some other API call,so the 
stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

關於bug起源的任何想法,它只是第一行代碼!

"cuda:2"

選擇系統中的第三個 GPU。 如果您的系統中(至少)沒有 3 個 GPU,您將收到此錯誤。

假設您至少有 1 個正確安裝並設置了可用的 CUDA GPU,請嘗試:

"cuda:0"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM