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

Issue running on Macbook Pro M1 #253

Closed
rm1238 opened this issue Jun 26, 2023 · 18 comments
Closed

Issue running on Macbook Pro M1 #253

rm1238 opened this issue Jun 26, 2023 · 18 comments

Comments

@rm1238
Copy link

rm1238 commented Jun 26, 2023

When running on Macbook Pro M1 I have run into an issue running rgt-hint.

I get the following -

OSError: dlopen(/Users/ivancorea/rgtdata/lib/librgt_mac.so, 0x0006): tried: '/Users/ivancorea/rgtdata/lib/librgt_mac.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ivancorea/rgtdata/lib/librgt_mac.so' (no such file), '/Users/ivancorea/rgtdata/lib/librgt_mac.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I see the librgt_mac_m1.so file installed but I cannot find where to explicitly make sure this library is used.

Are there additional flags that must be set when running rgt-hint on the M1? Any advice on getting past this error?

@lzj1769
Copy link
Member

lzj1769 commented Jul 3, 2023

Hi,

Could you show how you install the package on M1 Mac and the version of RGT?

You can get the version information by rgt-hint --version

@rm1238
Copy link
Author

rm1238 commented Jul 3, 2023

Hi Zhijian

I tried to install using the generic approach here [https://github.com/CostaLab/reg-gen].
Screenshot 2023-07-03 at 14 23 46

I have also used the Mac-specific approach described in your website here: [https://reg-gen.readthedocs.io/en/latest/rgt/installation.html]:
Screenshot 2023-07-03 at 14 23 01

I have RGT installed in my Intel Mac and it runs fine. I would like to install on the M1 Macs in my lab for my postdocs and students to use it.

Thanks a lot again for your help,

Ricardo

@rm1238
Copy link
Author

rm1238 commented Jul 5, 2023

This is the version of RGT:
Screenshot 2023-07-05 at 09 37 33

@lzj1769
Copy link
Member

lzj1769 commented Jul 6, 2023

Hi,

The latest version of develop branch is v1.0.1.
Can you try to install it from the source code?

To do so, you need to run the following commands:

git@github.com:CostaLab/reg-gen.git
git checkout develop
pip install ./

Please let me know if this fixes the issue on m1.

@rm1238
Copy link
Author

rm1238 commented Jul 12, 2023

When I do this it just reinstalls the 1.0.0 version. I downloaded from the 'develop' branch here
Screenshot 2023-07-12 at 12 49 14

After I install and run i get the same error
Screenshot 2023-07-12 at 12 49 50

I think I am not down getting to the 1.0.1 version you mention. I cannot get to the repository with this command: git@github.com:CostaLab/reg-gen.git. I was able to clone through GitHub Desktop and with gh as above, with the same results, downloading version 1.0.0.

Can you indicate how to get to the 1.0.1 version?

Thanks!

Ricardo

@lzj1769
Copy link
Member

lzj1769 commented Jul 12, 2023

Hi,

Sorry, the command to download RGT should be:

git clone git@github.com:CostaLab/reg-gen.git

Anyway, since you already downloaded the package through GitHub Desktop, you can switch to develop branch by

git checkout develop

Alternatively, you can try to install rgt via conda, which is what I usually do when running rgt,

  1. Install miniconda by following https://docs.conda.io/en/latest/miniconda.html
  2. Once you successfully install conda, create a specific environment for rgt by: conda create -n rgt python=3.6
  3. Activate your conda environment: conda activate rgt
  4. Install RGT package: pip install rgt

This will automatically install rgt (v1.0.0) with all its dependencies.

Please let me know if this solves your issue.

@rm1238
Copy link
Author

rm1238 commented Jul 13, 2023

Hello there,

I successfully installed the develop version 1.0.1 (see attached)

Screenshot 2023-07-13 at 13 59 58

However, I keep getting the same error (see attached)

Screenshot 2023-07-13 at 14 00 36

I am suspecting the issue may be the python version installed by homebrew? In my case this is 3.11. I cannot really think of what else it can be. I will try to install through conda, but before doing so, should I be using an earlier version of Python to install RGT?

@lzj1769
Copy link
Member

lzj1769 commented Jul 13, 2023

Hi,

Thanks for the feedback.

I didn't test rgt on python 3.11, for me, python 3.9 works well.

Regarding the error, I think it is because you are running python directly on M1 chip which is an arm64 architecture, and librgt_mac.so was complied for x86_64 through ROSETTA translation.

@rm1238
Copy link
Author

rm1238 commented Jul 13, 2023

Hi,

Is there a way to compile librgt_mac.so for arm64?

@lzj1769
Copy link
Member

lzj1769 commented Jul 13, 2023

Let me give it a try.

@rm1238
Copy link
Author

rm1238 commented Jul 13, 2023

Sounds good, thanks!

@rm1238
Copy link
Author

rm1238 commented Jul 17, 2023

Please keep me posted when you have news.

@lzj1769
Copy link
Member

lzj1769 commented Jul 19, 2023

Hi,

I installed rgt on my Mac M1 pro, and it worked well.

This means I couldn't reproduce your issue.

Could you provide more information about your python and platform?

You can type python and then:

import platform
platform.uname()

@rm1238
Copy link
Author

rm1238 commented Jul 19, 2023

Hi Zhijian,

Here the requested information. Hope this helps pinpoint the issue.

Screenshot 2023-07-18 at 21 08 41

@rm1238
Copy link
Author

rm1238 commented Jul 24, 2023

Hi Zhijian,

I reinstalled cleanly with Python 3.9 but am still getting the same error (see attached). Platform info also attached.

Screenshot 2023-07-24 at 1 26 14 PM Screenshot 2023-07-24 at 1 27 08 PM

@lzj1769
Copy link
Member

lzj1769 commented Jul 25, 2023

Hi,

Thanks for your feedback.

I finally can reproduce your error:

sh hint.sh 
**********************************************
Testing HINT
Running HINT using only DNase-seq data..
Downloading test data.
x HINT_DNaseTest/
x HINT_DNaseTest/DNase.bam
x HINT_DNaseTest/DNase.bam.bai
x HINT_DNaseTest/DNasePeaks.bed
Traceback (most recent call last):
  File "/opt/homebrew/bin/rgt-hint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/rgt/HINT/Main.py", line 95, in main
    args.func(args)
  File "/opt/homebrew/lib/python3.11/site-packages/rgt/HINT/Footprinting.py", line 112, in footprinting_run
    dnase_seq(args)
  File "/opt/homebrew/lib/python3.11/site-packages/rgt/HINT/Footprinting.py", line 529, in dnase_seq
    post_processing(footprints=footprints, original_regions=original_regions, fp_min_size=fp_min_size,
  File "/opt/homebrew/lib/python3.11/site-packages/rgt/HINT/Footprinting.py", line 812, in post_processing
    footprints_overlap = footprints.intersect(original_regions, mode=OverlapType.ORIGINAL)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/rgt/GenomicRegionSet.py", line 732, in intersect
    return self.intersect_c(y, mode, rm_duplicates)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/rgt/GenomicRegionSet.py", line 871, in intersect_c
    lib = cdll.LoadLibrary(Lib.get_c_rgt())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: dlopen(/Users/zhijianli/rgtdata/lib/librgt_mac.so, 0x0006): tried: '/Users/zhijianli/rgtdata/lib/librgt_mac.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/zhijianli/rgtdata/lib/librgt_mac.so' (no such file), '/Users/zhijianli/rgtdata/lib/librgt_mac.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I have modified the code to first check if it's being installed in arm64 or X86_64 platform, and now it works well with Arm64 platform.

To solve it, what you need to do is the following:

  1. Delete the rgtdata folder completely, otherise you might still have the x86_64 based library. You can find it in your home directory

  2. Pull the new version of RGT to your local machine. Since you already download the repo., you can first switch to develop branch by git checkout develop and then pull the code: git pull. If you think this is too complicated, you can wait until I release it on Pypi, then you just need to install it by pip install rgt

  3. After you installed it, please check if you a file called "librgt_mac_arm64.so" in your rgtdata/lib directory: ls ~/rgtdata/lib

The problem should be solved by following the above steps.

@rm1238
Copy link
Author

rm1238 commented Jul 25, 2023

Hi Zhijian,

I followed the last instructions and HINT is working perfectly fine on M1 Mac. Thanks again so much for your help.

@rm1238
Copy link
Author

rm1238 commented Jul 25, 2023

Thanks

@rm1238 rm1238 closed this as completed Jul 25, 2023
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

2 participants