esa / pygmo2

A Python platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pygmo2/
Mozilla Public License 2.0
414 stars 56 forks source link

[BUG] pygmo interferes with pytorch on Windows system #159

Closed CoolRunning closed 3 months ago

CoolRunning commented 3 months ago

Describe the bug Installing pytorch and pygmo in the same conda environment makes torch unusable.

To Reproduce Steps to reproduce the behavior: In a fresh and empy conda environment on Windows execute in the following order:

conda install python=3.9
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

verify that pytorch works by opening a python console

import torch
torch.rand(1)

break torch by installing pygmo

conda install pygmo

verify that pytorch stopped working in a python console

import torch

Screenshots Output of error in my system:

(deepl3) C:\projects>python
Python 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:38:46) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\mmarcus\miniconda3\envs\deepl3\lib\site-packages\torch\__init__.py", line 130, in <module>
    raise err
OSError: [WinError 182] The operating system cannot run %1. Error loading "C:\Users\mmarcus\miniconda3\envs\deepl3\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

Environment (please complete the following information):

Additional context

darioizzo commented 3 months ago

oh no! tricky to investigate .... but https://github.com/pytorch/pytorch/issues/89752 might be related? Maybe more a conda/pytorch issue than a pygmo one?

bluescarni commented 3 months ago

Unfortunately I don't think that mixing conda-forge with other channels is fully supported (though it may work in practice on some setups).

@CoolRunning isn't it possible to install directly torch from conda-forge?

CoolRunning commented 3 months ago

I tried installing torch from conda-forge with no success, but it might still be possible (did not try very hard). The current workaround that I found is installing pygmo with conda and torch with pip, following PyTorch

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

This allows CUDA as well (in the above case: CUDA 12.1). So far this seems workable, so I close the issue for now.

bluescarni commented 3 months ago

Man what a clusterfuck CUDA is. Glad that you managed to work around it!