0% found this document useful (0 votes)
6 views

Lab 1_ Configuring an Open-Source Linux Distribution for Machine Learning

This document outlines the steps to configure an open-source Linux distribution for machine learning, including the installation of Python, Jupyter Notebook, and essential ML libraries like TensorFlow and PyTorch. It also details basic security configurations such as user creation, SSH key authentication, and firewall setup. The conclusion emphasizes the successful establishment of a secure and optimized environment for ML development.

Uploaded by

sodayac916
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lab 1_ Configuring an Open-Source Linux Distribution for Machine Learning

This document outlines the steps to configure an open-source Linux distribution for machine learning, including the installation of Python, Jupyter Notebook, and essential ML libraries like TensorFlow and PyTorch. It also details basic security configurations such as user creation, SSH key authentication, and firewall setup. The conclusion emphasizes the successful establishment of a secure and optimized environment for ML development.

Uploaded by

sodayac916
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

This document is the property of Al Nafi.

Any unauthorized redistribution or reproduction, including in printed form, is strictly


prohibited. This document can only be read electronically.

Lab1: Configuring an Open-Source Linux Distribution for


Machine Learning

Objectives:

1. Install Python and Jupyter Notebook.


2. Set up essential ML libraries like TensorFlow, PyTorch, NumPy, and Pandas.

td
3. Implement basic security configurations and configure a firewall.

tl
Prerequisites:
1. Linux Distribution: An installed open-source Linux distribution such as Ubuntu 20.04

Pv
LTS.
2. Root or Sudo Access: Ability to execute commands with root privileges.
3. Internet Connection: To download and install packages.

ng
Tasks:

Step 1: Install Python and Jupyter Notebook


ni
ar
1.1 Update the System
Le

```bash
sudo apt update
sudo apt upgrade -y
IE

```

1.2 Install Python and Pip


AF

```bash
sudo apt install python3 python3-pip -y
```
N

2. **Verify the installation**:


AL

```bash
python3 --version
pip3 --version
```

Install Jupyter Notebook

```bash
pip3 install jupyter
```

```bash
jupyter notebook --generate-config
```

3. ```bash

td
jupyter notebook password
```

tl
```bash

Pv
jupyter notebook
```

Access Jupyter Notebook in your browser at `http://localhost:8888`.

ng
Step 2: Install Essential ML Libraries
1.
```bash
ni
ar
pip3 install numpy pandas matplotlib scikit-learn tensorflow keras torch
torchvision
Le

```

```bash
IE

python3
>>> import numpy, pandas, tensorflow as tf, torch
>>> print(numpy.__version__, pandas.__version__, tf.__version__,
AF

torch.__version__)
>>> exit()
```
N
AL

Step 3: Implement Basic Security Configurations


3.1 Create a New User for ML Development

```bash
sudo adduser mluser
sudo usermod -aG sudo mluser
```
```bash
su - mluser
```

3.2 Set Up SSH Key Authentication (Optional)

1. ```bash
ssh-keygen -t rsa -b 4096

td
```

tl
2. ```bash
ssh-copy-id mluser@your-server-ip

Pv
```

3. ```bash

ng
sudo nano /etc/ssh/sshd_config
```
- Set `PasswordAuthentication` to `no`.
ni
- Restart SSH service:
```bash
ar
sudo systemctl restart ssh
```
Le

3.3 Configure Firewall (UFW)


IE

1. ```bash
sudo apt install ufw -y
```
AF

2. ```bash
sudo ufw allow OpenSSH
N

```
AL

3. ```bash
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
```

4. ```bash
sudo ufw enable
```

5.```bash
sudo ufw status
```

3.4 Harden the System


1. ```bash

td
sudo apt install fail2ban -y
```

tl
Pv
2. ```bash
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure --priority=low unattended-upgrades

ng
```

Step 4: Test the Setup


ni
1. Create a simple Jupyter notebook to test the ML environment:
ar
Start Jupyter Notebook as `mluser`:
Le

```bash
jupyter notebook
```
IE

Create a new notebook and run basic commands to check if all installed libraries are working.

2. Test the firewall:


AF

- Ensure that only allowed services (SSH, HTTP, HTTPS) are accessible from outside.
- Attempt to access any blocked ports to confirm they are properly restricted.
N

Conclusion:
By following this lab, you've successfully configured an open-source Linux distribution tailored
AL

for machine learning development. You've installed Python, Jupyter, and essential ML libraries
while implementing basic security configurations such as creating a dedicated user, setting up
SSH key authentication, configuring a firewall with UFW, and hardening the system with
Fail2Ban and automatic updates. This setup provides a secure and optimized environment for
ML development.

You might also like