Skip to content

Conversation

@jeylau
Copy link
Contributor

@jeylau jeylau commented Oct 22, 2022

I paste below the simple steps to follow to get a working installation with python 3.9 and tensorflow 2.10:

We'll get the miniconda M1 bash installer, as explained in https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html. In the Terminal, run the following commands:

wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-MacOSX-arm64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
source ~/miniconda/bin/activate
conda init zsh

Then, clone DeepLabCut (git clone https://github.com/DeepLabCut/DeepLabCut.git), and run conda env create -f conda-environments/DEEPLABCUT_M1.yaml. Next, activate the environment (conda activate DEEPLABCUT_M1), and launch DLC with pythonw -m deeplabcut.

@jeylau jeylau requested a review from MMathisLab October 22, 2022 09:24
@jeylau jeylau self-assigned this Oct 22, 2022
@jeylau jeylau mentioned this pull request Oct 26, 2022
2 tasks
@MMathisLab
Copy link
Member

bringing in setup.py changes from PR #1970

Copy link
Member

@MMathisLab MMathisLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I found the miniconda install annoying, as it broke all my anaconda env, so that is a warning to users...

@MMathisLab MMathisLab self-requested a review October 29, 2022 12:40
@MMathisLab
Copy link
Member

MMathisLab commented Oct 29, 2022

EDIT: resolved!

@jeylau please address:

Testing on macbook intel chip (2020), v12.5.1:

git checkout m1m2

pip install -e '.[gui,tf]'

python -m deeplabcut

GUI launches, load demo openfield project,

Loading DLC 2.3rc1...
Starting GUI...
/Users/mwmathis/opt/anaconda3/envs/DEEPLABCUT/lib/python3.10/site-packages/qtpy/__init__.py:267: RuntimeWarning: Selected binding "pyside2" could not be found, using "pyside6"
  warnings.warn('Selected binding "{}" could not be found, '

edit config to extract 2 frames, go to extract, and it hangs on yes/no, which I cannot select ...
Screen Shot 2022-10-29 at 2 38 29 PM

have to hard crash out of it :(.

Next:

click "label frames":

Traceback (most recent call last):
  File "/Users/mwmathis/Documents/DeepLabCut/deeplabcut/gui/tabs/label_frames.py", line 31, in label_frames
    dialog.setFileMode(dialog.DirectoryOnly)
AttributeError: 'PySide6.QtWidgets.QFileDialog' object has no attribute 'DirectoryOnly'. Did you mean: 'directoryUrl'?

@MMathisLab MMathisLab changed the title Straightforward, functional installation on Apple Silicon Straightforward, functional installation on Apple Silicon // moving to PySide6 Oct 29, 2022
@jeylau
Copy link
Contributor Author

jeylau commented Oct 31, 2022

  • I found the miniconda install annoying, as it broke all my anaconda env, so that is a warning to users...

Yeah I agree...
Perhaps we could get anaconda arm64 from the bottom of that page, I'm not sure whether that would avoid breaking conda though.

@jeylau jeylau marked this pull request as draft November 2, 2022 16:17
@MMathisLab
Copy link
Member

MMathisLab commented Nov 2, 2022

Install now works great for me! Note, it does require miniconda3, as normal anaconda does fail ;) I had to check :)

but, when I run the python testscript.py it is missing tf_slim:

Loading DLC 2.3rc1...
DLC loaded in light mode; you cannot use any GUI (labeling, relabeling and standalone GUI)
  File "/Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/train.py", line 24, in <module>
    import tf_slim as slim
ModuleNotFoundError: No module named 'tf_slim'

so I need to run:
pip install tf_slim

then it runs 👍

@MMathisLab
Copy link
Member

but it seems to not download the model correctly:

❯ python testscript.py
Loading DLC 2.3rc1...
Imported DLC!
On Windows/OSX tensorpack is not tested by default.
CREATING PROJECT
Created "/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/videos"
Created "/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/labeled-data"
Created "/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/training-datasets"
Created "/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/dlc-models"
Copying the videos
/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/videos/reachingvideo1.avi
Generated "/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/config.yaml"

A new project with name TEST-Alex-2022-11-02 is created at /Users/mwmathis/Documents/DeepLabCut/examples and a configurable file (config.yaml) is stored there. Change the parameters in this file to adapt to your project's needs.
 Once you have changed the configuration file, use the function 'extract_frames' to select frames for labeling.
. [OPTIONAL] Use the function 'add_new_videos' to add new videos to your project (at any stage).
EXTRACTING FRAMES
Config file read successfully.
Extracting frames based on kmeans ...
Kmeans-quantization based extracting of frames from 0.0  seconds to 8.53  seconds.
Extracting and downsampling... 256  frames from the video.
256it [00:01, 176.07it/s]
Kmeans clustering ... (this might take a while)
Frames were successfully extracted, for the videos listed in the config.yaml file.

You can now label the frames using the function 'label_frames' (Note, you should label frames extracted from diverse videos (and many videos; we do not recommend training on single videos!)).
CREATING-SOME LABELS FOR THE FRAMES
Plot labels...
Creating images with labels by Alex.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00,  5.70it/s]
If all the labels are ok, then use the function 'create_training_dataset' to create the training dataset!
CREATING TRAININGSET
The training dataset is successfully created. Use the function 'train_network' to start training. Happy training!
CHANGING training parameters to end quickly!
TRAIN
Selecting single-animal trainer
Config:
{'all_joints': [[0], [1], [2], [3]],
 'all_joints_names': ['bodypart1', 'bodypart2', 'bodypart3', 'objectA'],
 'alpha_r': 0.02,
 'apply_prob': 0.5,
 'batch_size': 1,
 'contrast': {'clahe': True,
              'claheratio': 0.1,
              'histeq': True,
              'histeqratio': 0.1},
 'convolution': {'edge': False,
                 'emboss': {'alpha': [0.0, 1.0], 'strength': [0.5, 1.5]},
                 'embossratio': 0.1,
                 'sharpen': False,
                 'sharpenratio': 0.3},
 'crop_pad': 0,
 'cropratio': 0.4,
 'dataset': 'training-datasets/iteration-0/UnaugmentedDataSet_TESTNov2/TEST_Alex80shuffle1.mat',
 'dataset_type': 'default',
 'decay_steps': 30000,
 'deterministic': False,
 'display_iters': 2,
 'fg_fraction': 0.25,
 'global_scale': 0.8,
 'init_weights': '/Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/models/pretrained/resnet_v1_50.ckpt',
 'intermediate_supervision': False,
 'intermediate_supervision_layer': 12,
 'location_refinement': True,
 'locref_huber_loss': True,
 'locref_loss_weight': 0.05,
 'locref_stdev': 7.2801,
 'log_dir': 'log',
 'lr_init': 0.0005,
 'max_input_size': 1500,
 'mean_pixel': [123.68, 116.779, 103.939],
 'metadataset': 'training-datasets/iteration-0/UnaugmentedDataSet_TESTNov2/Documentation_data-TEST_80shuffle1.pickle',
 'min_input_size': 64,
 'mirror': False,
 'multi_stage': False,
 'multi_step': [[0.001, 5]],
 'net_type': 'resnet_50',
 'num_joints': 4,
 'optimizer': 'sgd',
 'pairwise_huber_loss': False,
 'pairwise_predict': False,
 'partaffinityfield_predict': False,
 'pos_dist_thresh': 17,
 'project_path': '/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02',
 'regularize': False,
 'rotation': 25,
 'rotratio': 0.4,
 'save_iters': 5,
 'scale_jitter_lo': 0.5,
 'scale_jitter_up': 1.25,
 'scoremap_dir': 'test',
 'shuffle': True,
 'snapshot_prefix': '/Users/mwmathis/Documents/DeepLabCut/examples/TEST-Alex-2022-11-02/dlc-models/iteration-0/TESTNov2-trainset80shuffle1/train/snapshot',
 'stride': 8.0,
 'weigh_negatives': False,
 'weigh_only_present_joints': False,
 'weigh_part_predictions': False,
 'weight_decay': 0.0001}
Batch Size is 1
/Users/mwmathis/miniconda/envs/DEEPLABCUT_M1/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer_v1.py:1694: UserWarning: `layer.apply` is deprecated and will be removed in a future version. Please use `layer.__call__` method instead.
  warnings.warn('`layer.apply` is deprecated and '
Metal device set to: Apple M1 Pro

systemMemory: 32.00 GB
maxCacheSize: 10.67 GB

2022-11-02 17:49:29.132517: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2022-11-02 17:49:29.132647: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
Loading ImageNet-pretrained resnet_50
2022-11-02 17:49:29.302387: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2022-11-02 17:49:29.302418: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
/Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/train.py:225: UserWarning: Switching to Adam, as SGD crashes on Apple Silicon.
  warnings.warn("Switching to Adam, as SGD crashes on Apple Silicon.")
2022-11-02 17:49:29.701147: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:354] MLIR V1 optimization pass is not enabled
2022-11-02 17:49:29.726137: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
2022-11-02 17:49:29.731388: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
2022-11-02 17:49:30.449692: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
2022-11-02 17:49:31.673542: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
Traceback (most recent call last):
  File "/Users/mwmathis/Documents/DeepLabCut/examples/testscript.py", line 164, in <module>
    deeplabcut.train_network(path_config_file)
  File "/Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/training.py", line 221, in train_network
    raise e
  File "/Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/training.py", line 210, in train_network
    train(
  File "/Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/train.py", line 242, in train
    restorer.restore(sess, cfg["init_weights"])
  File "/Users/mwmathis/miniconda/envs/DEEPLABCUT_M1/lib/python3.9/site-packages/tensorflow/python/training/saver.py", line 1407, in restore
    raise ValueError("The passed save_path is not a valid checkpoint: " +
ValueError: The passed save_path is not a valid checkpoint: /Users/mwmathis/Documents/DeepLabCut/deeplabcut/pose_estimation_tensorflow/models/pretrained/resnet_v1_50.ckpt

@jeylau
Copy link
Contributor Author

jeylau commented Nov 2, 2022

@MMathisLab, was this run on a M1 or M2 chip? (Although I'm not sure it makes a big difference)

@MMathisLab MMathisLab marked this pull request as ready for review November 4, 2022 13:10
@MMathisLab
Copy link
Member

alright, ALL solved! easy install, great work @jeylau :)

MMathisLab and others added 5 commits November 4, 2022 14:47
* Fix typo

* Fix failing tests (#2021)

* Fix pandas regression

* Update requirements.txt

* Update installation.md (#2020)

* Update installation.md

* Update installTips.md

* Update installation.md

* Add benchmark API (#1777)

* Add benchmark API
 Co-authored-by: Jessy <[email protected]>

* black formatting, added ref for datasets in benchmark

* Update installation.md (#2029)

Just a typo

Co-authored-by: Jessy Lauer <[email protected]>
Co-authored-by: Steffen Schneider <[email protected]>
Co-authored-by: AlexEMG <[email protected]>
Co-authored-by: Ale Santuz <[email protected]>
@MMathisLab MMathisLab mentioned this pull request Nov 4, 2022
@MMathisLab MMathisLab changed the title Straightforward, functional installation on Apple Silicon // moving to PySide6 Straightforward, functional installation on Apple Silicon // moving to PySide6 // rc2 Nov 4, 2022
@AlexEMG AlexEMG merged commit 993a640 into master Nov 4, 2022
@jeylau jeylau deleted the m1m2 branch November 8, 2022 08:44
jonahpearl pushed a commit to jonahpearl/DeepLabCut that referenced this pull request Nov 27, 2022
…o PySide6 // rc2 (DeepLabCut#2022)

* Drop pyside2 for pyside6
* Functional Apple Silicon conda environment file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants