# Issues Setting Up CUDA for PyTorch on Windows Using Anaconda

**URL:** <https://forums.developer.nvidia.com/t/issues-setting-up-cuda-for-pytorch-on-windows-using-anaconda/298553>\
**Category:** CUDA Setup and Installation\
**Tags:** cuda\
**Created:** [July 3, 2024, 4:42pm UTC](https://forums.developer.nvidia.com/t/issues-setting-up-cuda-for-pytorch-on-windows-using-anaconda/298553 "2024-07-03T16:42:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![darondaroq](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@darondaroq](https://forums.developer.nvidia.com/u/darondaroq)\
**Post date:** [July 3, 2024, 4:42pm UTC](https://forums.developer.nvidia.com/t/issues-setting-up-cuda-for-pytorch-on-windows-using-anaconda/298553/1 "2024-07-03T16:42:08Z")

</div>

Hello!

I am experiencing issues while trying to set up CUDA to use my GPU for training a neural network in a PyTorch project. I am using Anaconda on Windows, and I need to leverage the GPU for my project. Please help me understand what might be going wrong.

#### System Information:

- OS: Windows 10
- Anaconda: version 2023.03
- CUDA Toolkit: version 12.4
- PyTorch: latest version installed via conda
- Visual Studio: 2022 version 17.10.3

#### Description of the Problem:

After installing all the necessary components and attempting to build the project using CMake, I encounter the following error:

```auto
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\include\crt/host_config.h(153): fatal error C1189: 
#error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! 
The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; 
however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.

# --error 0x2 --

Call Stack (most recent call first):
  C:/Users/alexb/anaconda3/Library/share/cmake-3.26/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  C:/Users/alexb/anaconda3/Library/share/cmake-3.26/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
  C:/Users/alexb/anaconda3/Library/share/cmake-3.26/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
  cmake/public/cuda.cmake:47 (enable_language)
  cmake/Dependencies.cmake:43 (include)
  CMakeLists.txt:853 (include)

-- Configuring incomplete, errors occurred!

```

Additionally, when I run the command nvcc --version, I get the following output:

```auto
(base) C:\Users\alexb\pytorch>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Tue_Feb_27_16:28:36_Pacific_Standard_Time_2024
Cuda compilation tools, release 12.4, V12.4.99
Build cuda_12.4.r12.4/compiler.33961263_0

```

I have checked the versions of all installed components, and they should be compatible. And I verified the paths and settings in the Anaconda environment, and everything seems correct.

How can I correctly configure my environment to properly use CUDA with PyTorch on Windows via Anaconda?
