How to Set Up an M1 Mac Cluster Using Thunderbolt for Running DeepSeek

How to Set Up an M1 Mac Cluster Using Thunderbolt for Running DeepSeek
M1 Mac, Thunderbolt, Cluster, DeepSeek, MPI, IP-over-Thunderbolt, OpenMPI, Ray, Distributed Learning, Unified Memory

1. Concept of an M1 Mac Cluster with Thunderbolt

Although M1 Macs do not offer native clustering functionality like traditional x86 servers, they can leverage Thunderbolt 3/4 ports for high-speed networking. This allows distributed learning using MPI (Multi-Processing Interface).

Cluster Networking Options with Thunderbolt:

• Thunderbolt-to-Ethernet Bridge: Use Thunderbolt cables to connect multiple M1 Macs. In macOS network settings, configure an Ethernet Bridge to create a single network.

• IP-over-Thunderbolt: macOS supports Thunderbolt Bridge, enabling high-speed network connections that function like a typical TCP/IP network.

2. Cluster Setup Process

(1) Hardware Preparation

• Multiple M1 Macs (minimum of 2)

• Thunderbolt 3/4 cables (enough to connect all devices)

• A network router or a main Mac acting as the central bridge

(2) Configuring the Thunderbolt Network

1. Connect Macs Using Thunderbolt Cables:

• Use a daisy chain setup with one central Mac.

• Alternatively, connect all Macs to a single Thunderbolt Dock.

2. Enable IP-over-Thunderbolt:

• On each Mac, go to “System Settings” → “Network”.

• Add the “Thunderbolt Bridge” network interface.

• Assign a static IP to each Mac (e.g., 192.168.10.x range).

3. Test SSH Connections:

• Ensure all Macs can communicate via SSH.

• Use ssh-keygen to generate SSH keys and configure passwordless SSH access between nodes.

3. Software Setup for DeepSeek

To run the DeepSeek model, you need to configure the cluster for distributed learning.

(1) Python and PyTorch Installationbrew install python pip install torch torchvision torchaudio pip install torch --pre torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu # Optimized for M1

(2) Download and Run the DeepSeek Modelgit clone https://github.com/DeepSeek-AI/DeepSeek-LLM.git cd DeepSeek-LLM pip install -r requirements.txt

You will also need to download the model checkpoint from Hugging Face or another source.

(3) Configure MPI (Multi-Processing Interface)

M1 Mac clusters can use OpenMPI or Ray for distributed processing.

• Install OpenMPI:brew install open-mpi

• Example MPI Execution:mpirun -np 4 --hostfile hosts.txt python train.py

• Using Ray for Distributed Learning:

• On the head node:pip install ray ray start --head

• On each worker node:ray start --address=192.168.10.1:6379

4. Optimization and Management

1. Load Balancing: Use mpirun to control process distribution across nodes.

2. Memory Management: M1 Macs have unified memory; efficient management is crucial for training large models.

3. Use Docker: Leverage Apple Silicon-compatible Docker containers for easier deployment.docker pull deepseek/llm

5. Conclusion

Using Thunderbolt-based networking, you can create a high-speed M1 Mac cluster for distributed learning. This setup enables efficient data transfer, making it possible to train models like DeepSeek. However, due to the lack of GPU acceleration, you’ll need to focus on CPU-based optimization and use tools like OpenMPI or Ray to manage distributed workloads effectively.

Test this configuration and let me know if you encounter any issues! 🚀

Read more

토토와 단둘이 여수 여행

토토와 단둘이 여수 여행

이번엔 여수 여행이다. 단둘이 말이다. 토토맘은 제주로...나는 여수로....ㅋㅋㅋㅋ 아주 좋다. 편하다. 토토는 장시간 운전이 피곤한 모양새이다. 언제나 그렇듯이 녀석은 차로 이동하는건 별로인것 같다. 하지만 할수 없다. 대신 좋아라 하는 간식 북어체를 한봉지 사서 미안한 맘을 좀 표현해보고 최대한 산책도 많이 시켜주려 한다.

By ilikeafrica

일본 삿포로 오타루 여행

삿포로 여행중 오후 느즈막히 오타루행 JR 열차를 발권을 하고 정보 없는 곳으로 출발했다. 가면서 창밖으로 보이는 풍경은 아무래도 베를린의 동독 지역이었다. 일본과 독일이 그 옛날 왕래가 잦았다더니 이런 하나 하나 까지 서로가 맞았나부다. 트램도 그렇고 집짓는것도 그렇고 돌아보면 볼수록 동독 냄새가 너무 난단 말이지…. 우야튼 가는 도중 북해도의 파도를 본다.

By ilikeafrica
일본 삿포로 나까시마 공원

일본 삿포로 나까시마 공원

추석 기나긴 연휴 기간 다녀온 첫 일본 여행. 삿포로 시내에 호텔 잡고 5일밤을 주구장창 지낸다. 이젠 여행 스타일이 돌아다니기 보단 한곳에 오랫동안 머무르는게 일상이 되었다. 매일 짐 싸고 풀고 하는게 뭔 소용인가도 싶고, 그렇게 편히 즐기다 오는데 여행일듯하다. 처음 가본 일본. 그중에 삿포로. 눈 쌓인 겨울도 아니고, 단풍 빨간 가을도

By ilikeafrica