Skip to content

torchvision: Does not use the same compiler as torch when building with CUDA #217913

@ConnorBaker

Description

@ConnorBaker

Describe the bug

Unlike torch, torchvision does not explicitly set the C/C++ compiler when building with CUDA. This is problematic because we can end up linking libraries built by different versions of the compiler built with different language standards. Additionally, we can potentially end up using a compiler which isn't supported by the version of NVCC being used.

torch does this in the preConfigure phase:

preConfigure = lib.optionalString cudaSupport ''
export TORCH_CUDA_ARCH_LIST="${cudaFlags.cudaCapabilitiesSemiColonString}"
export CC=${cudatoolkit.cc}/bin/gcc CXX=${cudatoolkit.cc}/bin/g++
'' + lib.optionalString (cudaSupport && cudnn != null) ''

torchvision can do it in the same place or in preBuild:

preBuild = lib.optionalString cudaSupport ''
export TORCH_CUDA_ARCH_LIST="${cudaFlags.cudaCapabilitiesSemiColonString}"
export FORCE_CUDA=1
'';

Notify maintainers

@ericsagnes

cc @NixOS/cuda-maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.12-200.fc37.x86_64, Fedora Linux, 37 (Workstation Edition), nobuild`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.14.0pre20230208_ec78896`
 - channels(connorbaker): `"nixpkgs"`
 - nixpkgs: `/home/connorbaker/.nix-defexpr/channels/nixpkgs`

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: cudaParallel computing platform and API6.topic: pythonPython is a high-level, general-purpose programming language.
    No fields configured for issues without a type.

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions