jbonato1 / ASTRA

Astrocytes Semantic Segmentation
Apache License 2.0
5 stars 1 forks source link

Running ASTRA on Windows or on Colab #3

Closed PTRRupprecht closed 2 months ago

PTRRupprecht commented 2 months ago

Hi,

First of all, thanks for developing this very useful tool!

I have been trying to deploy the algorithm to some 2P recordings from hippocampal astrocytes (I was hoping that your pretrained model would work well for this purpose). However, for this purpose, I have currently a Windows machine available. Unfortunately, I was unable to install ASTRA - I could not install the correct python version (using conda), the correct packages (torch 1.2.0 was not supported by any python version that I was able to install), and has also not sure whether my CUDA driver version would be compatible ...

Therefore, I was asking myself whether it would be possible to run ASTRA on the cloud, e.g., on Colab. Based on my understanding of ASTRA, the input is only a single 2D image, so I don't think that the algorithm will use too many resources (and probably even does not require any sort of GPU). So it should be not too difficult to adapt your code such that it works in Colab. Have you tried so, or can you give some guidance on how you would do this (or whether you foresee any difficulties)?

Looking forward to hearing from you,

Best wishes, Peter

jbonato1 commented 2 months ago

Hi Peter,

In the "installation" folder, there is a Dockerfile that sets up the entire environment with Python 3.10 and CUDA 12.2. Using Docker, you can leverage your OS and GPUs.

ASTRA processes 2-photon Ca2+ imaging recordings, analyzing and manipulating these videos to create a 2D spatiotemporal map, which is then fed into the DNN.

Regards Jacopo

PTRRupprecht commented 2 months ago

Hi Jacopo,

Thanks for the quick reply! Also thanks for the clarification about how ASTRA works; I had been under the false impression that ASTRA only does segmentation of a 2D input - I might have mixed things up with CITE-ON and simply assumed that ASTRA does the same but for astrocytes. I have now read the preprint more carefully.

I would have prefered to make it work without Docker since I had previously mixed experience with Nvidia+Docker, but I will give it a try. I'll let you know if I'd encounter any major problems.

Best, Peter

PTRRupprecht commented 2 months ago

Hi @jbonato1,

I have a follow-up question on the installation of ASTRA with Docker.

I have now used the commands to generate docker images (docker pull nvidia/cuda:12.2.2-devel-ubuntu22.04 and docker build -t astro_segm:1.0 .) The images seem to have been generated properly:

Screenshot1

But when I try to run the images in Docker-Desktop, I get the following error (see error message on the right hand side), indicating that the installed CUDA version is wrong. It therefore seems to me that the docker container does not really use the docker-nvidia 12.2 version (the system's CUDA version is 11.8, but I pulled the 12.2 version for the nvidia-docker as in your installation instructions):

Screenshot2

Also when I run the code in the console (docker run -it -p 8888:8888 --gpus all -v /mnt/c/Users/Titan/Desktop/Sian-Peter-Packages/ASTRA-master astro_segm:1.0 bash), I get the very similar error:

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy' nvidia-container-cli: requirement error: unsatisfied condition: cuda>=12.2, please update your driver to a newer version, or use an earlier cuda container: unknown.

Do you have an idea what is going wrong here? How can I force the ASTRA container to use the nvidia-cuda image?

Your help would be appreciated!

Best, Peter

jbonato1 commented 2 months ago

Ok have you tested direcly the nvidia image nvidia/cuda:12.2.2-devel-ubuntu22.04? Does it work properly ?

i.e. RUN docker run -it --gpus all nvidia/cuda:12.3.1-devel-ubuntu22.04 bash and inside the running image nvidia-smi -l

Can you tell me which nvidia-driver do you have? and which GPU?

PTRRupprecht commented 2 months ago

Thanks for the quick reply. Testing the nvidia image results in the same error:

docker run -it --gpus all nvidia/cuda:12.2.2-devel-ubuntu22.04 bash

results in

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy' nvidia-container-cli: requirement error: unsatisfied condition: cuda>=12.2, please update your driver to a newer version, or use an earlier cuda container: unknown.

So I cannot really run nvidia-smi -l inside of the image, since I cannot run the nvidia image at all. When I run the command outside of the image, I see that the following drivers are installed: "NVIDIA-SMI 520.61.03 Driver Version: 522.06 CUDA Version: 11.8". The GPU in this computer is an NVIDIA GeForce RTX 3070.

I looks as if somehow the nvidia drivers seen are too old. Unfortunately, I don't fully understand whether nvidia drivers are installed fully inside or outside of the docker environment. If you have any further suggestions, it would be helpful.

P.S. Was there a specific reason why you indicated "12.2.2" in one place and "12.3.1" in another place in your last reply?

Best, Peter

jbonato1 commented 2 months ago

Sorry for this late reply. The problem is your driver version. 522 nvidia driver are not compatible with cuda 12. So there 2 options: you can use the cuda 12 image from dockerhub but you need to update the drivers (you can still use cuda 11 using docker or make multiple cuda installation in your os), or you can use your environment and install the packages required (most of them are standard in AI like numpy pandas torch opencv). Unfortunately I dont have time to customize everything for your OS and driver vesrion

PTRRupprecht commented 2 months ago

Hi @jbonato1, thanks for your reply. I also figured out that the driver incompatibility is a problem. Unfortunately, having multiple cuda version installed at the same time does not work. At the same time, I would like to keep the system compatible with already installed software (e.g., DeepLabCut). As you mentioned, this cannot be figured out remotely; I will try my best to find a solution and will report here (as a reference for others) once I've managed to make it work.

PTRRupprecht commented 2 months ago

Now it seems to work. I've updated the CUDA to 12.5 and the drivers such that they are compatible, both on Windows. With WSL-2, all attempts to install drivers in Ubuntu were not successful. I also don't think that it is possible in all cases to have multiple versions of CUDA working on the same computer in parallel.

After installing CUDA, I created a conda environment, installed the "requirements_updated.txt" with pip on the WSL-2 Ubuntu, and it seems to work now so far. I'm running into some other questions now, but these are unrelated to this current installation issue, and I will open another issue about that.