-
Notifications
You must be signed in to change notification settings - Fork 1
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
request: macOS installation instructions #1
Comments
using my text editor I asked Sonnet 3.5 for help making #!/bin/bash
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install base requirements
pip install flask laion_clap librosa numpy
# Install PyTorch with MPS support (nightly version for best M1/M2/M3 support)
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
# Create run script
cat > run.sh << 'EOF'
#!/bin/bash
source venv/bin/activate
python3 sound-similarity-browser.py
open http://localhost:5000/
EOF
# Make run script executable
chmod +x run.sh
# Run the application
./run.sh but need to make |
the script from Sonnet doesnt work because Error: (samplebrowser) dev@mac-m3pro: sample-browser % pip install laion_clap
Collecting laion_clap
Using cached laion_clap-1.1.6-py3-none-any.whl.metadata (26 kB)
Collecting numpy==1.23.5 (from laion_clap)
Using cached numpy-1.23.5.tar.gz (10.7 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
Traceback (most recent call last):
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
backend = _build_backend()
^^^^^^^^^^^^^^^^
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
obj = import_module(mod_path)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/Users/dev/Apps/IDE/CursorPy/cursor-portable-data/tmp/pip-build-env-d633a9m9/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
import setuptools.version
File "/Users/dev/Apps/IDE/CursorPy/cursor-portable-data/tmp/pip-build-env-d633a9m9/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/Users/dev/Apps/IDE/CursorPy/cursor-portable-data/tmp/pip-build-env-d633a9m9/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2172, in <module>
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
(samplebrowser) dev@mac-m3pro: sample-browser % Issue: numpy/numpy#23808 |
Sonnet is suggesting:
After running |
Ok new error related to (samplebrowser) dev@mac-m3pro: sample-browser % python3 sound-similarity-browser.py
tokenizer_config.json: 100%|█████████████████████████████████████████████████████████████| 48.0/48.0 [00:00<00:00, 57.2kB/s]
vocab.txt: 100%|█████████████████████████████████████████████████████████████████████████| 232k/232k [00:00<00:00, 2.96MB/s]
tokenizer.json: 100%|████████████████████████████████████████████████████████████████████| 466k/466k [00:00<00:00, 9.22MB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████████| 570/570 [00:00<00:00, 3.12MB/s]
tokenizer_config.json: 100%|██████████████████████████████████████████████████████████████| 25.0/25.0 [00:00<00:00, 142kB/s]
vocab.json: 100%|████████████████████████████████████████████████████████████████████████| 899k/899k [00:00<00:00, 26.1MB/s]
merges.txt: 100%|████████████████████████████████████████████████████████████████████████| 456k/456k [00:00<00:00, 35.4MB/s]
tokenizer.json: 100%|██████████████████████████████████████████████████████████████████| 1.36M/1.36M [00:00<00:00, 38.6MB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████████| 481/481 [00:00<00:00, 2.58MB/s]
vocab.json: 100%|████████████████████████████████████████████████████████████████████████| 899k/899k [00:00<00:00, 49.8MB/s]
merges.txt: 100%|████████████████████████████████████████████████████████████████████████| 456k/456k [00:00<00:00, 37.8MB/s]
tokenizer.json: 100%|██████████████████████████████████████████████████████████████████| 1.36M/1.36M [00:00<00:00, 46.5MB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████| 1.72k/1.72k [00:00<00:00, 7.30MB/s]
/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/torch/functional.py:539: UserWarnin
/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/torch/functional.py:539: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /User
/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/torch/functional.py:539: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/native/TensorShape.cpp:4312.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
model.safetensors: 100%|██████████████████████████████████████████████████████████████████| 499M/499M [00:04<00:00, 104MB/s]
Some weights of RobertaModel were not initialized from the model checkpoint at roberta-base and are newly initialized: ['rob
Some weights of RobertaModel were not initialized from the model checkpoint at roberta-base and are newly initialized: ['roberta.pooler.dense.bias', 'roberta.pooler.dense.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Load our best checkpoint in the paper.
Downloading laion_clap weight files...
100% [....................................................................] 1863587645 / 1863587645Download completed!
Load Checkpoint...
Traceback (most recent call last):
File "/Users/dev/code/ml/music/classification/sample-browser/sound-similarity-browser.py", line 112, in <module>
browser = SoundSimilarityBrowser()
File "/Users/dev/code/ml/music/classification/sample-browser/sound-similarity-browser.py", line 15, in __init__
self.model.load_ckpt()
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/laion_clap/hook.py", line 1
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/laion_clap/hook.py", line 113, in load_ckpt
ckpt = load_state_dict(ckpt, skip_params=True)
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/laion_clap/clap_module/fact
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/laion_clap/clap_module/factory.py", line 54, in load_state_dict
checkpoint = torch.load(checkpoint_path, map_location=map_location)
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/torch/serialization.py", li
File "/Users/dev/code/ml/music/classification/sample-browser/venv/lib/python3.10/site-packages/torch/serialization.py", line 1488, in load
raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those st
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `Tru
(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code exec
(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error messag
(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray.scalar was not an allowed global by default
WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray.scalar was not an allowed global by default. Please use `torch.serialization.add_safe_globals([scalar])` or the `torch.serialization.safe_globals([scalar])` context ma
WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray.scalar was not an allowed global by default. Please use `torch.serialization.add_safe_globals([scalar])` or the `torch.serialization.safe_globals([scalar])` context manager to allowlist this global if you trust this class/function.
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/do
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html. Sonnet is suggesting an edit to the
def __init__(self, cache_file: str = "embeddings_cache.jsonl"):
torch.serialization.add_safe_globals([np.core.multiarray.scalar])
self.model = laion_clap.CLAP_Module(enable_fusion=False)
self.model.load_ckpt()
self.cache_file = cache_file
self.embeddings_cache: Dict[str, List[float]] = {}
self.load_cache() |
The original pip install -U torch==2.4.0+cu121 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 So it makes sense to edit the #!/bin/bash
# Create and activate virtual environment
python3.10 -m venv --prompt samplebrowser venv
source venv/bin/activate
# Install base requirements
pip install --upgrade pip setuptools wheel packaging
pip install flask laion_clap librosa
# Install PyTorch with MPS support (nightly version for best M1/M2/M3 support)
pip install torch==2.4.0 torchvision torchaudio
# Create run script
cat > run.sh << 'EOF'
#!/bin/bash
source venv/bin/activate
python3 sound-similarity-browser.py
open http://localhost:5000/
EOF
# Make run script executable
chmod +x run.sh
# Run the application
./run.sh Slight edits to the original:
|
not sure what it is about
Even when I edit the The weird thing is visiting I see |
Ok Sonnet gave me a few ideas but fixing the audio path issues in the script is probably beyond the scope of this issue. Going to open a PR with changes to the README on how to install this for mac. |
One other weird thing I encountered using this repo on macOS is because I added a piece to the python3 sound-similarity-browser.py &
PID=$! # Capture the background process ID
sleep 15
open http://127.0.0.1:5000/
# Wait for Ctrl+C
trap "kill $PID" INT
wait $PID If I hit
Which also means maybe we should use a port other than 5000. Also, any time I would make an edit to These are just additional thoughts. I'm leaving this alone for now. |
The goal is to create installation instructions that works for Mac devices.
Want to use this as an archive of thoughts as I'm working through the set up.
Here are my specs:
The text was updated successfully, but these errors were encountered: