Skip to content

ice13ball/wsl_ubuntu_startScripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash Scripts for System Setup

This directory contains scripts for automating system configuration, particularly useful for WSL/Ubuntu environments.

Recommended Execution Order

  1. no_sudo.sh - Configure passwordless sudo (optional, reduces password prompts)
  2. setup_dotfiles.sh - Link configuration files (dotfiles) from a central source.
  3. install_essentials.sh - Base system packages and tools
  4. cuda_install.sh - CUDA and ML environment setup

Note: Running no_sudo.sh first minimizes password prompts during installation. If security is a concern, skip this step and be prepared to enter your password multiple times.

Windows Setup for CUDA in WSL

Before running cuda_install.sh, ensure your Windows host meets these requirements:

  1. System Requirements:

    • Windows 10/11 (Build 20150 or later)
    • WSL 2 enabled (run wsl --set-default-version 2 in PowerShell)
    • NVIDIA GPU with driver version 470.14 or newer
  2. Windows-side Installation:

  3. WSL Configuration:

    • Ensure WSL 2 is default:
      wsl --set-default-version 2
    • Install Ubuntu from Microsoft Store
  4. Verification:

    • In PowerShell:
      nvidia-smi
    • In WSL:
      lspci | grep -i nvidia
  5. Troubleshooting:

    • If nvidia-smi fails in WSL:
      1. Update Windows NVIDIA drivers
      2. Reinstall CUDA Toolkit
      3. Restart WSL (wsl --shutdown)
    • Check WSL version:
      wsl -l -v

Note: The Windows CUDA toolkit version should match or be newer than the version installed in WSL.

Script Documentation

1. no_sudo.sh

Purpose: Configures passwordless sudo for the current user.

Features:

  • Creates backup of sudoers file
  • Adds NOPASSWD rule for current user
  • Sets proper file permissions

Usage:

./no_sudo.sh

WARNING:

  • This reduces system security
  • Only recommended for development environments
  • Revert with: sudo rm /etc/sudoers.d/99_nopasswd_*

2. setup_dotfiles.sh

Purpose: Manages and synchronizes user configuration files (dotfiles) from a central location, ensuring a consistent environment across multiple shells or WSL instances.

Features:

  • Supports two sources: a local directory on the Windows host or a remote Git repository.
  • Automatically creates symbolic links for your configuration files (e.g., .bashrc, .gitconfig).
  • Safely backs up any existing local dotfiles before creating new links.

Usage:

# Option 1: Sync from a folder on your Windows machine
./setup_dotfiles.sh --source windows --path "C:\Users\YourUser\dotfiles"

# Option 2: Sync from a Git repository
./setup_dotfiles.sh --source git --repo "https://github.com/your-user/dotfiles.git"

Options:

  • --source [windows|git]: Required. Specify the source type.
  • --path <path>: The absolute path to your dotfiles folder on Windows (used with --source windows).
  • --repo <url>: The URL of your dotfiles Git repository (used with --source git).

3. install_essentials.sh

Purpose: Installs fundamental development tools and configures a basic environment.

Features:

  • Installs essential packages (build-essential, git, vim, etc.).
  • Configures bash aliases and terminal colors idempotently (won't add duplicates).
  • Installs Node.js 18, Python tools, and Docker Community Edition.
  • Provides guidance for VS Code integration within WSL.

Usage:

./install_essentials.sh

Notes:

  • Requires sudo privileges
  • Some changes require restarting the terminal or starting a new shell session.

4. cuda_install.sh

Purpose: Installs the CUDA toolkit and ML frameworks with GPU support in a self-contained Python environment.

Features:

  • Auto-detects the recommended CUDA version based on popular ML frameworks.
  • Performs full security verification of the CUDA installer (GPG+SHA256).
  • Creates a Python virtual environment to avoid system-wide conflicts.
  • Installs PyTorch, TensorFlow, and JAX with corresponding CUDA support.
  • Includes robust error handling and automatic cleanup of temporary files.

Usage:

# Basic usage with defaults
./cuda_install.sh

# Specify a Python version and custom environment name
./cuda_install.sh --python-version 3.10 --env-name my-ml-env

Options:

  • --python-version: Specify Python version (e.g., 3, 3.9, 3.10).
  • --env-name: Set a custom name for the virtual environment.
  • --env-path: Define a custom path for the virtual environment.

Requirements:

  • NVIDIA drivers must be installed on the Windows host.
  • An existing CUDA installation will be detected and the script will exit to prevent overwriting.

Security Considerations

  1. no_sudo.sh significantly reduces security - use with caution.
  2. setup_dotfiles.sh can execute remote code if using an untrusted Git repository.
  3. cuda_install.sh and install_essentials.sh download and install packages from official and third-party repositories.
  4. All scripts require internet access.

Maintenance

To update all scripts from your Git repository:

git pull origin main

To verify script integrity:

sha256sum *.sh

Releases

No releases published

Packages

No packages published

Languages