Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to install libtorch without CUDA / cudnn / GPU? #42799

Open
HoLue opened this issue Dec 19, 2024 · 8 comments
Open

Is it possible to install libtorch without CUDA / cudnn / GPU? #42799

HoLue opened this issue Dec 19, 2024 · 8 comments
Assignees
Labels
category:question This issue is a question

Comments

@HoLue
Copy link

HoLue commented Dec 19, 2024

Copy issue body from D:/di/Libraries/Vs/vcpkg/installed/vcpkg/issue_body.md

Is it possible to install without CUDA / cudnn / GPU?

I've done:
vcpkg install libtorch:x64-windows

I got:
Computing installation plan...
The following packages will be built and installed:

  • blas:x64-windows@2023-04-14#1
  • cpuinfo:x64-windows@2022-07-19#3
  • cuda:[email protected]#13
  • cudnn:[email protected]#14
  • fftw3:[email protected]#9
  • fmt:[email protected]#1
  • foxi:x64-windows@2021-12-01
  • fp16:x64-windows@2021-02-21#2
  • fxdiv:x64-windows@2021-02-21#2
  • gemmlowp:x64-windows@2021-09-28
  • gflags:[email protected]#9
  • glog:[email protected]
  • lapack:x64-windows@2023-06-10#2
  • lapack-reference[blas-select,core,noblas]:[email protected]#6
    libtorch[core,cuda,opencv,zstd]:[email protected]#7
  • lmdb:[email protected]
  • magma:[email protected]#1
  • mimalloc:[email protected]#1
  • nvidia-cutlass:[email protected]
  • onnx:[email protected]
  • onnx-optimizer:[email protected]
  • openblas:[email protected]
  • opencl:[email protected]
  • opencv[core,default-features]:[email protected]#1
  • pocketfft:x64-windows@2023-09-25
  • psimd:x64-windows@2021-02-21#2
  • pthreadpool:x64-windows@2020-04-10#3
  • sleef:[email protected]#4
  • vcpkg-gfortran:x64-windows@3#3
  • xnnpack:x64-windows@2022-12-22
    Additional packages (*) will be modified to complete this operation.
    Detecting compiler hash for triplet x64-windows...
    Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exeRestored 0 package(s) from C:\Users\hl\AppData\Local\vcpkg\archives in 6.94 ms. Use --debug to see more details.
    Installing 1/30 openblas:[email protected]...
    Building openblas:[email protected]...
    -- Downloading https://patch-diff.githubusercontent.com/raw/OpenMathLib/OpenBLAS/pull/4926.diff?full_index=1 -> openblas-fix-arm64-windows-uwp.patch...
    -- Downloading https://github.com/OpenMathLib/OpenBLAS/archive/v0.3.28.tar.gz -> OpenMathLib-OpenBLAS-v0.3.28.tar.gz...
    -- Extracting source D:/di/Libraries/Vs/vcpkg/downloads/OpenMathLib-OpenBLAS-v0.3.28.tar.gz
    -- Applying patch uwp.patch
    -- Applying patch fix-redefinition-function.patch
    -- Applying patch install-tools.patch
    -- Applying patch gcc14.patch
    -- Applying patch D:/di/Libraries/Vs/vcpkg/downloads/openblas-fix-arm64-windows-uwp.patch
    -- Using source at D:/di/Libraries/Vs/vcpkg/buildtrees/openblas/src/v0.3.28-6f3e63eb38.clean
    -- Downloading https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_54001_64bit_UCRT/strawberry-perl-5.40.0.1-64bit-portable.zip -> strawberry-perl-5.40.0.1-64bit-portable.zip...
    -- Found external ninja('1.12.1').
    -- Configuring x64-windows
    -- Building x64-windows-dbg
    -- Building x64-windows-rel
    -- Fixing pkgconfig file: D:/di/Libraries/Vs/vcpkg/packages/openblas_x64-windows/lib/pkgconfig/openblas.pc
    -- Using cached msys2-mingw-w64-x86_64-pkgconf-12.3.0-1-any.pkg.tar.zst.
    -- Using cached msys2-msys2-runtime-3.5.4-2-x86_64.pkg.tar.zst.
    -- Using msys root at D:/di/Libraries/Vs/vcpkg/downloads/tools/msys2/21caed2f81ec917b
    -- Fixing pkgconfig file: D:/di/Libraries/Vs/vcpkg/packages/openblas_x64-windows/debug/lib/pkgconfig/openblas.pc
    -- Installing: D:/di/Libraries/Vs/vcpkg/packages/openblas_x64-windows/share/openblas/copyright
    -- Performing post-build validation
    Stored binaries in 1 destinations in 1.3 s.
    Elapsed time to handle openblas:x64-windows: 3.1 min
    openblas:x64-windows package ABI: 399907692d18d6dea31219f03cdeaf916ed84fdd9e8468351197628ee836fecd
    Installing 2/30 blas:x64-windows@2023-04-14#1...
    Building blas:x64-windows@2023-04-14#1...
    -- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
    Stored binaries in 1 destinations in 35.6 ms.
    Elapsed time to handle blas:x64-windows: 169 ms
    blas:x64-windows package ABI: 6e5e9aebd99702046d09b866f7df2c21d4d2f47ffdeb1a52c846de1cd2633bc8
    Installing 3/30 cpuinfo:x64-windows@2022-07-19#3...
    Building cpuinfo:x64-windows@2022-07-19#3...
    -- Note: cpuinfo only supports static library linkage. Building static library.
    -- Downloading https://github.com/pytorch/cpuinfo/archive/5e63739504f0f8e18e941bd63b2d6d42536c7d90.tar.gz -> pytorch-cpuinfo-5e63739504f0f8e18e941bd63b2d6d42536c7d90.tar.gz...
    -- Extracting source D:/di/Libraries/Vs/vcpkg/downloads/pytorch-cpuinfo-5e63739504f0f8e18e941bd63b2d6d42536c7d90.tar.gz
    -- Using source at D:/di/Libraries/Vs/vcpkg/buildtrees/cpuinfo/src/42536c7d90-2a15ca16d1.clean
    -- Found external ninja('1.12.1').
    -- Configuring x64-windows
    -- Building x64-windows-dbg
    -- Building x64-windows-rel
    -- Fixing pkgconfig file: D:/di/Libraries/Vs/vcpkg/packages/cpuinfo_x64-windows/lib/pkgconfig/libcpuinfo.pc
    -- Using cached msys2-mingw-w64-x86_64-pkgconf-1
    2.3.0-1-any.pkg.tar.zst.
    -- Using cached msys2-msys2-runtime-3.5.4-2-x86_64.pkg.tar.zst.
    -- Using msys root at D:/di/Libraries/Vs/vcpkg/downloads/tools/msys2/21caed2f81ec917b
    -- Fixing pkgconfig file: D:/di/Libraries/Vs/vcpkg/packages/cpuinfo_x64-windows/debug/lib/pkgconfig/libcpuinfo.pc
    -- Installing: D:/di/Libraries/Vs/vcpkg/packages/cpuinfo_x64-windows/share/cpuinfo/copyright
    -- Performing post-build validation
    Stored binaries in 1 destinations in 88.4 ms.
    Elapsed time to handle cpuinfo:x64-windows: 5 s
    cpuinfo:x64-windows package ABI: a740dc2c5897837227473b59a949eca99516b7a8052aad6fec422d06bc735115
    Installing 4/30 cuda:[email protected]#13...
    Building cuda:[email protected]#13...
    -- Found CUDA V11.0.221
    -- Installing: D:/di/Libraries/Vs/vcpkg/packages/cuda_x64-windows/share/cuda/copyright
    -- Performing post-build validation
    Stored binaries in 1 destinations in 29.6 ms.
    Elapsed time to handle cuda:x64-windows: 217 ms
    cuda:x64-windows package ABI: bb864d1c37aa56ab8e7f1f33e40f0b58954fdf5ed2127ae2a5888a16de76928a
    Installing 5/30 cudnn:[email protected]#14...
    Building cudnn:[email protected]#14...
    -- Found CUDA V11.0.221
    -- CUDNN_INCLUDE_DIR: CUDNN_INCLUDE_DIR-NOTFOUND
    -- CUDNN_LIBRARY: CUDNN_LIBRARY-NOTFOUND
    CMake Error at ports/cudnn/portfile.cmake:62 (message):
    Please download CUDNN from official sources
    (https://developer.nvidia.com/cudnn) and install it
    Call Stack (most recent call first):
    scripts/ports.cmake:192 (include)

error: building cudnn:x64-windows failed with: BUILD_FAILED
See https://learn.microsoft.com/vcpkg/troubleshoot/build-failures?WT.mc_id=vcpkg_inproduct_cli for more information.
Elapsed time to handle cudnn:x64-windows: 139 ms
Please ensure you're using the latest port files with git pull and vcpkg update.
Then check for known issues at:
https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+cudnn
You can submit a new issue at:
https://github.com/microsoft/vcpkg/issues/new?title=[cudnn]+Build+error+on+x64-windows&body=Copy+issue+body+from+D%3A%2Fdi%2FLibraries%2FVs%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

Copy link

Please see #30604 for how to properly report a build failure.

@HoLue HoLue changed the title [cudnn] Build error on vcpkg install libtorch:x64-windows Is it possible to install libtorch without CUDA / cudnn / GPU? Dec 20, 2024
@HoLue
Copy link
Author

HoLue commented Dec 20, 2024

Sorry thought *.md was included automatically. here it is:

Package: cudnn:[email protected]#14

Host Environment

Host: x64-windows
Compiler: MSVC 19.42.34435.0
vcpkg-tool version: 2024-10-18-e392d7347fe72dff56e7857f7571c22301237ae6 vcpkg-scripts version: 9d163f061 2024-11-05 (6 weeks ago)

To Reproduce

vcpkg install libtorch:x64-windows

Failure logs

-- Found CUDA V11.0.221
-- CUDNN_INCLUDE_DIR: CUDNN_INCLUDE_DIR-NOTFOUND
-- CUDNN_LIBRARY: CUDNN_LIBRARY-NOTFOUND
CMake Error at ports/cudnn/portfile.cmake:62 (message):
Please download CUDNN from official sources
(https://developer.nvidia.com/cudnn) and install it
Call Stack (most recent call first):
scripts/ports.cmake:192 (include)

@HoLue
Copy link
Author

HoLue commented Dec 20, 2024

There is a recommodation what to do, but that's somehow very difficult on my system. therefore the question if I can install without cuda, cudnn, gpu.

@MonicaLiu0311 MonicaLiu0311 added the category:question This issue is a question label Dec 20, 2024
@JoergAtGithub
Copy link
Contributor

I've the same issue, libtorch is a generic library, which should build without the GPU drivers of a third-party vendor. My system does not have a NVIDIA GPU, why should I install their drivers to build libtorch?

@dg0yt
Copy link
Contributor

dg0yt commented Dec 21, 2024

CUDA is required for the port's default feature cuda. To suppress default features at the command line, use the core pseudo-feature and explicitly include all desired features, e.g.

vcpkg install libtorch[core,zstd]

In manifest mode, use a libtorch dependency with "default-features": false.

@HoLue
Copy link
Author

HoLue commented Dec 21, 2024

@dg0yt Thanks!! May I ask which features are default? (Where can I find out? Actually as I am no expert therein I want to install all default features except cuda.)

@dg0yt
Copy link
Contributor

dg0yt commented Dec 21, 2024

The immediate source is the port's manifest:

"default-features": [
{
"name": "cuda",
"platform": "windows & !x86"
},
"opencv",
"zstd"
],

There is no "global" list, but the active default features vary subject to platform expressions. On vcpkg.link, you will find some features marked with Default Feature and the relevant expression:
https://vcpkg.link/ports/libtorch

On a linux console, the following also works for me:

vcpkg install --dry-run libtorch | grep libtorch
    libtorch[core,opencv,zstd]:[email protected]#8

(You see the effect of the windows & !x86 expression.)

@HoLue
Copy link
Author

HoLue commented Dec 22, 2024

@dg0yt Thanks a lot! This owrks somehow in principle. Now I have an error compiling onnx-optimizer, something with protobuf.... I created another ticket therefore:
#42854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

4 participants