DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Aditya Kanekar
Aditya Kanekar

Posted on

Installing SciSpacy on Apple M1 Laptops

Background

I was working on developing a API based on SciSpacy to search for medical terms. Looking at the slow performance of loading the model and entity linker on the Intel i5 chip on my Lenovo laptop, I was curious to check how the Apple M1 chip would perform since I own a MacBook Air with M1 chip with following specifications,

  • RAM - 16GB
  • Storage - 512GB SSD
  • Apple M1 chip
    • 8-core CPU with 4 performΒ­ance cores and 4 efficiency cores
    • 8-core GPU
    • 16-core Neural Engine

The Process

Following are the dependencies from requirement.txt file for SciSpacy and the en_core_sci_lg model,

scispacy==0.5.0
https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.0/en_core_sci_lg-0.5.0.tar.gz
Enter fullscreen mode Exit fullscreen mode

The ** pip install -r requirement.txt ** failed with lot of errors while installing a dependency ** nmslib ** with an error ** clang compiler does not support '-march=native' **. Since I already had the Xcode installed on my Mac the version of C was 11 but somehow the mentioned command was failing, since the said argument was not supported on the C version. With a lot of digging around I finally found a solution mentioned on SciSpacy GitHub page.

Install the nmslib using following command,

CFLAGS="-mavx -DWARN(a)=(a)" pip install nmslib
Enter fullscreen mode Exit fullscreen mode

After running this command all the packages got installed as expected and I was able to load and run the queries on SciSpacy model.

Next I will be coming up with the performance comparison on Apple M1 vs Intel i5 chip. I understand the comparison isn't fair but it just shows how much improved the M1 Chip is over the Intel processors.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.