AndreWeiner / ml-cfd-lecture

Lecture material for machine learning applied to computational fluid mechanics
GNU General Public License v3.0
330 stars 116 forks source link

the pytorch1.12.1+cpu is unable to be installed #38

Closed smallduan closed 5 months ago

smallduan commented 5 months ago

Hi While I am configuring my pyhon environment, I am facing problem, it shows that pytorch doesn't contain this version of package anymore, if I can install oter version instead? image

smallduan commented 5 months ago

I also try to install the torch1.12.1 cpu by myself, but it still failed image

image

AndreWeiner commented 5 months ago

Hi @smallduan, thanks for reporting the issue. I assume you are working with a fairly recent OS version, e.g., Ubuntu 24.04? Switching to a newer version of the PyTorch Python package will introduce a version conflict with the C++ frontend (libTorch). So, to run drlFoam with a newer version of PyTorch you need to:

  1. edit the requirements.txt file in the drlFoam folder and set the version to the latest available version (or leave out the version specification)
    pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
  2. install the new packages in the virtual environment
  3. remove the libtorch folder within drlFoam
  4. edit the setup-env in the drlFoam folder and switch to the latest version of libTorch (2.3.1):
    if [ ! -d $DRL_TORCH ];
    then
        echo "Could not find libTorch dependencies. Downloading libTorch to ${DRL_TORCH}"
        wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.1%2Bcpu.zip && \
        unzip libtorch-cxx11-abi-shared-with-deps-2.3.1+cpu.zip
        rm libtorch-cxx11-abi-shared-with-deps-2.3.1+cpu.zip
    fi
  5. run Allwmake to check if the code compiles with the latest version (not tested)

Please let me know if this works for you. Best, Andre

smallduan commented 5 months ago

Hi Thank you, It works for me.