segment-anything-models-java / SAMJ-IJ

An ImageJ/Fiji plugin designed to effortlessly integrate Segment-Anything models (SAMs) without code.
Apache License 2.0
50 stars 5 forks source link

Fails when trying to install Micromamba #15

Open comatose-tortoise opened 7 months ago

comatose-tortoise commented 7 months ago

Trying to test this plugin but when at the step of installing a model, it fails immediately when trying to install Micromamba.

Sonoma 14.4 M3 Max

Console shows this:

java.io.IOException: Failed to create Micromamba default directory /. Please try installing it in another directory.
    at io.bioimage.modelrunner.apposed.appose.Mamba.decompressMicromamba(Mamba.java:401)
    at io.bioimage.modelrunner.apposed.appose.Mamba.installMicromamba(Mamba.java:426)
    at ai.nets.samj.SamEnvManager.installMambaPython(SamEnvManager.java:951)
    at ai.nets.samj.SamEnvManager.installEfficientSAMSmall(SamEnvManager.java:998)
    at ai.nets.samj.gui.SAMModelPanel.lambda$createInstallationThread$7(SAMModelPanel.java:311)
    at java.base/java.lang.Thread.run(Thread.java:829)

I already have Mamba installed using Homebrew. Why is it trying to install Micromamba?

carlosuc3m commented 7 months ago

HEllo @comatose-tortoise thanks for giving SAMJ a try!

Where is you Fiji distribution installed? I have observed that installation fails if it is on the Downloads folder of a Mac.

SAMJ installs micromamba to avoid altering the user installation. Downloading its own micromamba it ensures complete control over the environments

comatose-tortoise commented 7 months ago

It is located in the Applications dir. I installed it to run natively on Apple Silicon using this: https://github.com/ij-plugins/ijp-imagej-launcher#installing-fiji-on-mac-os-x-arm64

Could that be why It's not working?

carlosuc3m commented 7 months ago

mmm i doubt it, it seems that the error is related to permissions when trying to create the folder appose_arm64 inside of the Fiji folder.

Could you try moving Fiji to another directory, for example Documents?

comatose-tortoise commented 7 months ago

Nope, same thing happens if I start it from Documents.

carlosuc3m commented 7 months ago

can you paste error again please? To see if there is something diffreent

comatose-tortoise commented 7 months ago
java.io.IOException: Failed to create Micromamba default directory /. Please try installing it in another directory.
    at io.bioimage.modelrunner.apposed.appose.Mamba.decompressMicromamba(Mamba.java:401)
    at io.bioimage.modelrunner.apposed.appose.Mamba.installMicromamba(Mamba.java:426)
    at ai.nets.samj.SamEnvManager.installMambaPython(SamEnvManager.java:951)
    at ai.nets.samj.SamEnvManager.installEfficientSAMSmall(SamEnvManager.java:998)
    at ai.nets.samj.gui.SAMModelPanel.lambda$createInstallationThread$7(SAMModelPanel.java:311)
    at java.base/java.lang.Thread.run(Thread.java:829)

Identical as far as I can see

xulman commented 7 months ago

Failed to create Micromamba default directory /. .. to root directory !?

in my case (Linux) the micromamba ended up in my home directory maybe the home folder resolution is failing on some Mac OSes?

xulman commented 7 months ago

so it actually wants to find where your Fiji.app is so that it can create the appose_... folder in it

this is what happened

java.io.IOException: Failed to create Micromamba default directory /home/ulman/Apps/Fiji_SAMJ.app. Please try installing it in another directory.
    at io.bioimage.modelrunner.apposed.appose.Mamba.decompressMicromamba(Mamba.java:401)

(that's my path to my Fiji with SAMJ) when I set

dr-xr-xr-x 1 ulman users 432 Mar 21 14:45 Fiji_SAMJ.app/
xulman commented 7 months ago

@comatose-tortoise I know this is not the ideal (and final) solution can you, pls, maybe try to place your Fiji to some innocent folder like /temp/abcd/FIji.app.. something that's not a "hot OS folder"?

xulman commented 7 months ago

(all these Documents, Desktop, Downloads, Program Files,App or Apps on Mac.... should be fine... but one never knows.. I live happier since I started avoiding them)

xulman commented 7 months ago

@comatose-tortoise I have just checked our src code and it seems we're doing something that can be reproduced from Fiji using the .py Jython script: Screenshot_20240321_150401

what does this do on your side?

carlosuc3m commented 7 months ago

yes it is weird that on certain Macs it has problems finding the current working dir. Do you have any idea @xulman ?

I will try to dig deeper on this issue and get back to you @comatose-tortoise

comatose-tortoise commented 7 months ago

@xulman

Screenshot 2024-03-21 at 17 09 40
carlosuc3m commented 7 months ago

maybe remove the space in File("vlado") .getAbsolutePath to File("vlado").getAbsolutePath ?

comatose-tortoise commented 7 months ago

Nope, same error

xulman commented 7 months ago

and try to change the type of the file/script to Python, in the menu language... or just rename to .py

xulman commented 7 months ago

Screenshot_20240321_174915

comatose-tortoise commented 7 months ago

@xulman

You're absolutely right, I had selected Java for some reason 🤯

image

I have no idea where it created "vlad", though.

xulman commented 7 months ago

it didn't create anything, it only created an object representing certain path....

on many systems, Google says, the (Java) construct new File("folder_name") should represent a path to the /current_working_directory/folder_name... apparently not your system... there it represents root_folder/folder_name which is what the test is saying... and on most unix systems one cannot create files in root folder (unless one is root)

thank you for the test, we have now confirmed (we believe :-) ) the source of the problem, @carlosuc3m and myself we would create a fix ASAP and let you know here

comatose-tortoise commented 7 months ago

Awesome!

xulman commented 7 months ago

@comatose-tortoise

Can we still ask you for one experiment? (please :pray: )

from java.lang import System
from java.io import File
from java.nio.file import FileSystems

# this one we're using, Baeldung says "nonstadard" way
print("Path = "+ File("").getAbsolutePath())

# these two should be standard
# this one Baeldung described w/o any further restrictions
print("CWD  = "+ System.getProperty("user.dir"))
#
# this one is theoretically available since java1.7,
# despite very old I could still imagine that some systems
# might have not adopted using it...
print("NIO  = "+ FileSystems.getDefault().getPath("").toAbsolutePath().toString() )

# user home as a backup backup?? not sure, better to stop and complain instead
print("user home = "+System.getProperty("user.home"))

what would be the outcome of that Jython script in Fiji, please?

comatose-tortoise commented 7 months ago

This is the output:

Started New_.py at Fri Mar 22 13:23:41 CET 2024
Path = /
CWD  = /
NIO  = /
user home = /Users/<username>
xulman commented 7 months ago

@comatose-tortoise thank you very much for the quick test

(it turned out the problem is actually little different that we thought originally, still we see light at the end of the tunnel :-) )

mnietodiaz commented 4 months ago

Hello, I have a similar problem. I am trying to install SAMJ models in my computer without success. Can you provide some help?

My computer is a Mac-Book Air (13-inch, 2017) using a 1.8 Ghz Intel Core i5 double nuclei processor with 8 Gbyte 1600 Mhz DDR3 memory, Intel HD Graphics 6000 1536 Mbytes, running under macOS Big Sur (11.7.0) Operating System. I am using the last update of FIJI imageJ2, version 2.14.0/1.54f, Java 1.8.0_172 (64-bit)

I got this error message:

java.lang.RuntimeException: Error executing the following command: [/Applications/Fiji.app/appose_x86_64/bin/micromamba, create, -p, /Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env, -c, conda-forge, python=3.11, -c, pytorch, libpng, libjpeg-turbo, scikit-image, pytorch=2.0.1, torchvision=0.15.2, cpuonly, mkl=2024.0.0, cmake, onnx, onnxruntime, timm=0.6.13, --yes] 09:03:41 -- STARTING INSTALLATION

09:04:31 -- TERMINATED PROCESS f503ba9f-e9bd-4f3f-8bdc-ce473e345967error libmamba Could not solve for environment specs f503ba9f-e9bd-4f3f-8bdc-ce473e345967The following package could not be installed f503ba9f-e9bd-4f3f-8bdc-ce473e345967└─ mkl 2024.0.0** does not exist (perhaps a typo or a missing channel). f503ba9f-e9bd-4f3f-8bdc-ce473e345967critical libmamba Could not solve for environment specs at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1196) at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1218) at io.bioimage.modelrunner.apposed.appose.Mamba.create(Mamba.java:665) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:652) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:626) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAM(SamEnvManager.java:1058) at ai.nets.samj.gui.SAMModelPanel.lambda$createInstallationThread$7(SAMModelPanel.java:321) at java.lang.Thread.run(Thread.java:748)

Thanks a lot in advance

Manuel Nieto Díaz

carlosuc3m commented 4 months ago

could you open a terminal, execute the following command and tell me the output?

/Applications/Fiji.app/appose_x86_64/bin/micromamba install -p /Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env -c conda-forge mkl=2024.0.0 --yes

mnietodiaz commented 4 months ago

Hi, The answer I got is the following:

(base) MacBook-Air-de-Manuel:~ manolo$ /Applications/Fiji.app/appose_x86_64/bin/micromamba install -p /Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env -c conda-forge mkl=2024.0.0 --yes info libmamba ** Backtrace Start ** debug libmamba Loading configuration trace libmamba Compute configurable 'create_base' trace libmamba Compute configurable 'no_env' trace libmamba Compute configurable 'no_rc' trace libmamba Compute configurable 'rc_files' trace libmamba Compute configurable 'root_prefix' trace libmamba Get RC files configuration from locations up to HomeDir trace libmamba Configuration not found at '/Users/manolo/.mambarc' trace libmamba Configuration not found at '/Users/manolo/.mamba/mambarc.d' trace libmamba Configuration not found at '/Users/manolo/.mamba/mambarc' trace libmamba Configuration not found at '/Users/manolo/.mamba/.mambarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/mambarc.d' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/mambarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/.mambarc' trace libmamba Configuration found at '/Users/manolo/.condarc' trace libmamba Configuration not found at '/Users/manolo/.conda/condarc.d' trace libmamba Configuration not found at '/Users/manolo/.conda/condarc' trace libmamba Configuration not found at '/Users/manolo/.conda/.condarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/../conda/condarc.d' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/../conda/condarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/../conda/.condarc' trace libmamba Configuration not found at '/Users/manolo/micromamba/.mambarc' trace libmamba Configuration not found at '/Users/manolo/micromamba/condarc.d' trace libmamba Configuration not found at '/Users/manolo/micromamba/condarc' trace libmamba Configuration not found at '/Users/manolo/micromamba/.condarc' trace libmamba Configuration not found at '/var/lib/conda/.mambarc' trace libmamba Configuration not found at '/var/lib/conda/condarc.d/' trace libmamba Configuration not found at '/var/lib/conda/condarc' trace libmamba Configuration not found at '/var/lib/conda/.condarc' trace libmamba Configuration not found at '/etc/conda/.mambarc' trace libmamba Configuration not found at '/etc/conda/condarc.d/' trace libmamba Configuration not found at '/etc/conda/condarc' trace libmamba Configuration not found at '/etc/conda/.condarc' trace libmamba Update configurable 'no_env' trace libmamba Compute configurable 'envs_dirs' trace libmamba Compute configurable 'file_specs' trace libmamba Compute configurable 'spec_file_env_name' trace libmamba Compute configurable 'env_name' trace libmamba Compute configurable 'use_target_prefix_fallback' trace libmamba Compute configurable 'target_prefix' trace libmamba Get RC files configuration from locations up to TargetPrefix trace libmamba Configuration not found at '/Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env/.mambarc' trace libmamba Configuration not found at '/Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env/condarc.d' trace libmamba Configuration not found at '/Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env/condarc' trace libmamba Configuration not found at '/Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env/.condarc' trace libmamba Configuration not found at '/Users/manolo/.mambarc' trace libmamba Configuration not found at '/Users/manolo/.mamba/mambarc.d' trace libmamba Configuration not found at '/Users/manolo/.mamba/mambarc' trace libmamba Configuration not found at '/Users/manolo/.mamba/.mambarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/mambarc.d' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/mambarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/.mambarc' trace libmamba Configuration found at '/Users/manolo/.condarc' trace libmamba Configuration not found at '/Users/manolo/.conda/condarc.d' trace libmamba Configuration not found at '/Users/manolo/.conda/condarc' trace libmamba Configuration not found at '/Users/manolo/.conda/.condarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/../conda/condarc.d' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/../conda/condarc' trace libmamba Configuration not found at '/Users/manolo/.config/mamba/../conda/.condarc' trace libmamba Configuration not found at '/Users/manolo/micromamba/.mambarc' trace libmamba Configuration not found at '/Users/manolo/micromamba/condarc.d' trace libmamba Configuration not found at '/Users/manolo/micromamba/condarc' trace libmamba Configuration not found at '/Users/manolo/micromamba/.condarc' trace libmamba Configuration not found at '/var/lib/conda/.mambarc' trace libmamba Configuration not found at '/var/lib/conda/condarc.d/' trace libmamba Configuration not found at '/var/lib/conda/condarc' trace libmamba Configuration not found at '/var/lib/conda/.condarc' trace libmamba Configuration not found at '/etc/conda/.mambarc' trace libmamba Configuration not found at '/etc/conda/condarc.d/' trace libmamba Configuration not found at '/etc/conda/condarc' trace libmamba Configuration not found at '/etc/conda/.condarc' trace libmamba Update configurable 'no_env' trace libmamba Compute configurable 'relocate_prefix' trace libmamba Compute configurable 'target_prefix_checks' error libmamba No prefix found at: /Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env error libmamba Environment must first be created with "micromamba create -n {env_name} ..." critical libmamba Aborting. info libmamba ** Backtrace End **** (base) MacBook-Air-de-Manuel:~ manolo$

El 11 jun 2024, a las 12:28, carlosuc3m @.***> escribió:

/Applications/Fiji.app/appose_x86_64/bin/micromamba install -p /Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env -c conda-forge mkl=2024.0.0 --yes

carlosuc3m commented 4 months ago

okay, could you try this now?

/Applications/Fiji.app/appose_x86_64/bin/micromamba create -p /Applications/Fiji.app/appose_x86_64/envs/example -c conda-forge mkl=2024.0.0 --yes

mnietodiaz commented 4 months ago

Still an error

(base) MacBook-Air-de-Manuel:~ manolo$ /Applications/Fiji.app/appose_x86_64/bin/micromamba create -p /Applications/Fiji.app/appose_x86_64/envs/example -c conda-forge mkl=2024.0.0 --yes conda-forge/osx-64 No change conda-forge/noarch No change bioconda/noarch No change r/osx-64 No change bioconda/osx-64 No change r/noarch No change pkgs/r/noarch No change pkgs/r/osx-64 No change pkgs/main/noarch No change error libmamba Could not solve for environment specs The following package could not be installed └─ mkl 2024.0.0** does not exist (perhaps a typo or a missing channel). critical libmamba Could not solve for environment specs

El 11 jun 2024, a las 14:19, carlosuc3m @.***> escribió:

/Applications/Fiji.app/appose_x86_64/bin/micromamba create -p /Applications/Fiji.app/appose_x86_64/envs/example -c conda-forge mkl=2024.0.0 --yes

carlosuc3m commented 4 months ago

Great thanks! The error seems a little bit more clear now. I will fix it and get you back!

mnietodiaz commented 4 months ago

Great, tx a lot

El 11 jun 2024, a las 14:28, carlosuc3m @.***> escribió:

Great thanks! The error seems a little bit more clear now. I will fix it and get you back!

— Reply to this email directly, view it on GitHub https://github.com/segment-anything-models-java/SAMJ-IJ/issues/15#issuecomment-2160636564, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3A4XHAEPKSJ2SA7VCUD2WTZG3UOZAVCNFSM6AAAAABFBGOAG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQGYZTMNJWGQ. You are receiving this because you commented.

mhadders commented 4 months ago

Hi,

Would be great to hear since I'm running into the same issue I think.

13:25:20 -- STARTING INSTALLATION

13:25:42 -- TERMINATED PROCESS13:30:47 -- STARTING INSTALLATION 13:30:47 -- conda-forge/osx-64 Using cache 13:30:47 -- conda-forge/noarch Using cache 13:30:47 -- pytorch/osx-64 Using cache 13:30:47 -- pytorch/noarch Using cache

13:30:54 -- TERMINATED PROCESS 87945514-37f5-4969-92ae-2056b031eba4error libmamba Could not solve for environment specs 87945514-37f5-4969-92ae-2056b031eba4The following package could not be installed 87945514-37f5-4969-92ae-2056b031eba4└─ mkl 2024.0.0** does not exist (perhaps a typo or a missing channel). 87945514-37f5-4969-92ae-2056b031eba4critical libmamba Could not solve for environment specs87945514-37f5-4969-92ae-2056b031eba4critical libmamba Could not solve for environment specs at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1196) at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1218) at io.bioimage.modelrunner.apposed.appose.Mamba.create(Mamba.java:665) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:652) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:626) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAM(SamEnvManager.java:1058) at ai.nets.samj.gui.SAMModelPanel.lambda$createInstallationThread$7(SAMModelPanel.java:313) at java.lang.Thread.run(Thread.java:750)

This is on 3,1 GHz 6-Core Intel Core i5 running MAC OS 14.4.1 java version "1.8.0_371" Fiji version: 2.14.0/1.54j

Any help is appreciated.

Regards

Michael

FrancisFSU commented 4 months ago

I am running same issures on my iMacPro 11:17:29 -- TERMINATED PROCESS 41db4c0e-a35e-4312-987c-d21aa848b645error libmamba Could not solve for environment specs 41db4c0e-a35e-4312-987c-d21aa848b645The following package could not be installed 41db4c0e-a35e-4312-987c-d21aa848b645└─ mkl 2024.0.0** does not exist (perhaps a typo or a missing channel). 41db4c0e-a35e-4312-987c-d21aa848b645critical libmamba Could not solve for environment specs

at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1196)
at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1218)
at io.bioimage.modelrunner.apposed.appose.Mamba.create(Mamba.java:665)
at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:652)
at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:626)
at ai.nets.samj.install.SamEnvManager.installEfficientViTSAM(SamEnvManager.java:1058)
at ai.nets.samj.gui.SAMModelPanel.lambda$createInstallationThread$7(SAMModelPanel.java:313)
at java.lang.Thread.run(Thread.java:748)

java.lang.RuntimeException: Error executing the following command: [/Applications/Fiji.app/appose_x86_64/bin/micromamba, create, -p, /Applications/Fiji.app/appose_x86_64/envs/efficientvit_sam_env, -c, conda-forge, python=3.11, -c, pytorch, libpng, libjpeg-turbo, scikit-image, pytorch=2.0.1, torchvision=0.15.2, cpuonly, mkl=2024.0.0, cmake, onnx, onnxruntime, timm=0.6.13, --yes] 11:17:06 -- STARTING INSTALLATION

11:17:29 -- TERMINATED PROCESS11:18:23 -- STARTING INSTALLATION 11:18:23 -- conda-forge/osx-64 Using cache 11:18:23 -- conda-forge/noarch Using cache 11:18:23 -- pytorch/osx-64 Using cache 11:18:23 -- pytorch/noarch Using cache

11:18:29 -- TERMINATED PROCESS 41db4c0e-a35e-4312-987c-d21aa848b645error libmamba Could not solve for environment specs 41db4c0e-a35e-4312-987c-d21aa848b645The following package could not be installed 41db4c0e-a35e-4312-987c-d21aa848b645└─ mkl 2024.0.0 does not exist (perhaps a typo or a missing channel). 41db4c0e-a35e-4312-987c-d21aa848b645critical libmamba Could not solve for environment specs 41db4c0e-a35e-4312-987c-d21aa848b645error libmamba Could not solve for environment specs 41db4c0e-a35e-4312-987c-d21aa848b645The following package could not be installed 41db4c0e-a35e-4312-987c-d21aa848b645└─ mkl 2024.0.0 does not exist (perhaps a typo or a missing channel). 41db4c0e-a35e-4312-987c-d21aa848b645critical libmamba Could not solve for environment specs at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1196) at io.bioimage.modelrunner.apposed.appose.Mamba.runMamba(Mamba.java:1218) at io.bioimage.modelrunner.apposed.appose.Mamba.create(Mamba.java:665) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:652) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAMPython(SamEnvManager.java:626) at ai.nets.samj.install.SamEnvManager.installEfficientViTSAM(SamEnvManager.java:1058) at ai.nets.samj.gui.SAMModelPanel.lambda$createInstallationThread$7(SAMModelPanel.java:315) at java.lang.Thread.run(Thread.java:748)

mnietodiaz commented 4 months ago

Great thanks! The error seems a little bit more clear now. I will fix it and get you back!

Fixed, great work Carlos Thanks a lot

carlosuc3m commented 1 week ago

hello @comatose-tortoise could you please test if it is still failing?