torch.cuda.set_device¶ torch.cuda.set_device(device)[原始碼][原始碼]¶ 設定目前裝置。 不鼓勵使用此函數,建議改用device。 在大多數情況下,最好使用 CUDA_VISIBLE_DEVICES 環境變數。 參數 device (torch.device 或 int) – 選取的裝置。 如果此引數為負數,則此函數不執行任何操作。