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

Installing for GPU processing: file environment_gpu.yaml has disapeared #935

Closed
aloboa opened this issue Mar 14, 2025 · 6 comments
Closed

Comments

@aloboa
Copy link

aloboa commented Mar 14, 2025

Trying to make a new source installation on linux, I observe that after
git clone https://github.com/computational-cell-analytics/micro-sam

the file environment_gpu.yaml is not there any more. I see files:

environment_cpu_win.yaml 
environment_gpu_win.yaml  
environment.yaml

If I compare the new environment.yaml to the former environment_gpu.yaml,
I observe that dependency
pytorch-cuda>=11.7

is not there any more.

Is this correct? may I go and use the current environment.yaml
mamba env create -f environment.yaml
and still get a micro-sam installation able to work with my GPU?

@constantinpape
Copy link
Contributor

Yes, this is correct. The reason for this is that the installation on Linux is now simplified because we use the pytorch package from conda-forge, which automatically installs the correct pytorch version for your machine.

So using mamba env create -f environment.yaml should give you a micro-sam installation that uses the GPU.

To test this you can run the following in the terminal (after you have installed and activated the environment):

python -c "import pytorch; print(torch.cuda.is_available())"

This should print out True; if it does you have a working GPU environment.

@aloboa
Copy link
Author

aloboa commented Mar 14, 2025

Unfortunately, after:

(base) alobo2@alobo-ws:~/micro-sam2/micro-sam$ mamba env create -f environment.yaml
Retrieving notices: done
Channels:
 - conda-forge
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
    current version: 24.11.2
    latest version: 25.1.1

Please update conda by running

    $ conda update -n base -c conda-forge conda



Downloading and Extracting Packages:
                                                                                                                                               
Preparing transaction: done                                                                                                                    
Verifying transaction: done                                                                                                                    
Executing transaction: | By downloading and using the cuDNN conda packages, you accept the terms and conditions of the NVIDIA cuDNN EULA -     
  https://docs.nvidia.com/deeplearning/cudnn/sla/index.html                                                                                    
                                                                                                                                               
/                                                                                                                                              
/                                                                                                                                              
/                                                                                                                                              
done                                                                                                                                           
Installing pip dependencies: \ Ran pip subprocess with arguments:                                                                              
['/home/alobo2/miniforge3/envs/sam2/bin/python', '-m', 'pip', 'install', '-U', '-r', '/home/alobo2/micro-sam2/micro-sam/condaenv.iovp2920.requirements.txt', '--exists-action=b']                                                                                                             
Pip subprocess output:                                                                                                                         
Collecting git+https://github.com/ChaoningZhang/MobileSAM.git (from -r /home/alobo2/micro-sam2/micro-sam/condaenv.iovp2920.requirements.txt (line 1))                                                                                                                                         
  Cloning https://github.com/ChaoningZhang/MobileSAM.git to /tmp/pip-req-build-4b1g_kb4                                                        
  Resolved https://github.com/ChaoningZhang/MobileSAM.git to commit 34bbbfdface3c18e5221aa7de6032d7220c6c6a1                                   
  Preparing metadata (setup.py): started                                                                                                       
  Preparing metadata (setup.py): finished with status 'done'                                                                                   
Building wheels for collected packages: mobile_sam                                                                                             
  Building wheel for mobile_sam (setup.py): started                                                                                            
  Building wheel for mobile_sam (setup.py): finished with status 'done'                                                                        
  Created wheel for mobile_sam: filename=mobile_sam-1.0-py3-none-any.whl size=42443 sha256=9f7806359ee9058b51891c554dde76e2bf3979374201970ad03ee2d9408b621a                                                                                                                                   
  Stored in directory: /tmp/pip-ephem-wheel-cache-h68h5j9_/wheels/5f/88/d6/5c0b5d4d64a06e19190d50269d8725c8aeadb128c966801af5                  
Successfully built mobile_sam                                                                                                                  
Installing collected packages: mobile_sam                                                                                                      
Successfully installed mobile_sam-1.0  

I get napari with no micro-sam:

Image

and with no CLI

base) alobo2@alobo-ws:~/micro-sam2/micro-sam$ conda activate sam2
(sam2) alobo2@alobo-ws:~/micro-sam2/micro-sam$ micro_sam.train
micro_sam.train: command not found

@anwai98
Copy link
Collaborator

anwai98 commented Mar 14, 2025

Hi @aloboa,

With installations from source, you always need to install the package locally:

cd micro-sam
pip install -e .

@constantinpape
Copy link
Contributor

And make sure to activate the environment before running the command @anwai98 indicates:

mamba activate sam2

@aloboa
Copy link
Author

aloboa commented Mar 14, 2025

Oops... shame on me...
Working with it now. Thanks

@aloboa aloboa closed this as completed Mar 14, 2025
@aloboa
Copy link
Author

aloboa commented Mar 18, 2025

Just realised that:

alobo2@alobo-ws:~$ conda activate sam2
(sam2) alobo2@alobo-ws:~$ python -c "import pytorch; print(torch.cuda.is_available())"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pytorch'

Despite the fact that micro-sam works with cuda (as shown by nvtop):

Image

(BTW, why is the training stopping after Epoch 57?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants