{"id":1331,"date":"2024-10-21T14:17:41","date_gmt":"2024-10-21T14:17:41","guid":{"rendered":"https:\/\/zahiralam.com\/blog\/?p=1331"},"modified":"2024-10-21T14:33:10","modified_gmt":"2024-10-21T14:33:10","slug":"run-powerful-ai-models-on-ubuntu-without-a-gpu-easy-bitnet-installation-guide","status":"publish","type":"post","link":"https:\/\/zahiralam.com\/blog\/run-powerful-ai-models-on-ubuntu-without-a-gpu-easy-bitnet-installation-guide\/","title":{"rendered":"Run Powerful AI Models on Ubuntu Without a GPU: Easy BitNet Installation Guide"},"content":{"rendered":"\n<p>BitNet is a powerful framework for running efficient AI models on your Ubuntu system using 1-bit quantization. This guide provides a quick installation process for Ubuntu, covering necessary dependencies, setup steps, advantages, disadvantages, and frequently asked questions.\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Update System Packages<\/strong><\/h3>\n\n\n\n<p>Before installing BitNet, make sure your system is up-to-date:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-1\">sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20update%20%26%26%20sudo%20apt%20upgrade%20-y\">\n                            <button class=\"copy-button\" data-label=\"sudo apt update &amp;&amp; sudo apt upgrade -y\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Install Dependencies<\/strong><\/h3>\n\n\n\n<p>BitNet requires several dependencies, including CMake, Clang, Git, and Python. Install them with the following commands:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-2\">sudo apt install -y cmake clang git python3 python3-pip<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20install%20-y%20cmake%20clang%20git%20python3%20python3-pip\">\n                            <button class=\"copy-button\" data-label=\"sudo apt install -y cmake clang git python3 python3-pip\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Verify your Python installation:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-3\">python3 --version<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python3%20--version\">\n                            <button class=\"copy-button\" data-label=\"python3 --version\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Install Conda (Recommended)<\/strong><\/h3>\n\n\n\n<p>Conda is recommended for managing dependencies and environments efficiently. If you don\u2019t have Conda installed, follow the steps below:\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download the Miniconda installer:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-4\">wget https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#wget%20https%3A%2F%2Frepo.anaconda.com%2Fminiconda%2FMiniconda3-latest-Linux-x86_64.sh\">\n                            <button class=\"copy-button\" data-label=\"wget https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Run the installer:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-5\">bash Miniconda3-latest-Linux-x86_64.sh<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#bash%20Miniconda3-latest-Linux-x86_64.sh\">\n                            <button class=\"copy-button\" data-label=\"bash Miniconda3-latest-Linux-x86_64.sh\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Follow the on-screen instructions and restart your terminal once the installation is complete.\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Initialize Conda:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-6\">conda init bash<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20init%20bash\">\n                            <button class=\"copy-button\" data-label=\"conda init bash\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>Restart your terminal for the changes to take effect.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Clone the BitNet Repository<\/strong><\/h3>\n\n\n\n<p>Navigate to the directory where you want to clone the BitNet repository:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-7\">cd ~\/Documents<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#cd%20~%2FDocuments\">\n                            <button class=\"copy-button\" data-label=\"cd ~\/Documents\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Clone the repository:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-8\">git clone --recursive https:\/\/github.com\/microsoft\/BitNet.git\ncd BitNet<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#git%20clone%20--recursive%20https%3A%2F%2Fgithub.com%2Fmicrosoft%2FBitNet.git%0Acd%20BitNet\">\n                            <button class=\"copy-button\" data-label=\"git clone --recursive https:\/\/github.com\/microsoft\/BitNet.git\ncd BitNet\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Create a Conda Environment for BitNet<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new environment for BitNet:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-9\">conda create -n bitnet-env python=3.9<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20create%20-n%20bitnet-env%20python%3D3.9\">\n                            <button class=\"copy-button\" data-label=\"conda create -n bitnet-env python=3.9\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Activate the environment:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-10\">conda activate bitnet-env<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20activate%20bitnet-env\">\n                            <button class=\"copy-button\" data-label=\"conda activate bitnet-env\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Install Python Dependencies<\/strong><\/h3>\n\n\n\n<p>Once the environment is active, install the required Python packages using the <code>requirements.txt<\/code> file provided:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-11\">pip install -r requirements.txt<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20-r%20requirements.txt\">\n                            <button class=\"copy-button\" data-label=\"pip install -r requirements.txt\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 7: Build BitNet from Source<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Set up the environment using the provided script:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-12\">python setup_env.py --hf-repo HF1BitLLM\/Llama3-8B-1.58-100B-tokens -q i2_s<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20setup_env.py%20--hf-repo%20HF1BitLLM%2FLlama3-8B-1.58-100B-tokens%20-q%20i2_s\">\n                            <button class=\"copy-button\" data-label=\"python setup_env.py --hf-repo HF1BitLLM\/Llama3-8B-1.58-100B-tokens -q i2_s\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Alternatively, manually download the model from Hugging Face and set it up:<\/li>\n<\/ol>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-13\">huggingface-cli download HF1BitLLM\/Llama3-8B-1.58-100B-tokens --local-dir models\/Llama3-8B-1.58-100B-tokens\npython setup_env.py -md models\/Llama3-8B-1.58-100B-tokens -q i2_s<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#huggingface-cli%20download%20HF1BitLLM%2FLlama3-8B-1.58-100B-tokens%20--local-dir%20models%2FLlama3-8B-1.58-100B-tokens%0Apython%20setup_env.py%20-md%20models%2FLlama3-8B-1.58-100B-tokens%20-q%20i2_s\">\n                            <button class=\"copy-button\" data-label=\"huggingface-cli download HF1BitLLM\/Llama3-8B-1.58-100B-tokens --local-dir models\/Llama3-8B-1.58-100B-tokens\npython setup_env.py -md models\/Llama3-8B-1.58-100B-tokens -q i2_s\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong> The models compatible with BitNet can be found at <a href=\"https:\/\/huggingface.co\/HF1BitLLM\" target=\"_blank\" rel=\"noreferrer noopener\">HF1BitLLM<\/a>. This repository contains pre-quantized models suitable for use with BitNet.\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 8: Run Inference<\/strong><\/h3>\n\n\n\n<p>Test the setup by running an inference command:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-14\">python run_inference.py -m models\/Llama3-8B-1.58-100B-tokens\/ggml-model-i2_s.gguf -p &quot;The cat sat on the mat. The dog lay in the garden. Where is the dog?\\nAnswer:&quot; -n 5 -temp 0<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20run_inference.py%20-m%20models%2FLlama3-8B-1.58-100B-tokens%2Fggml-model-i2_s.gguf%20-p%20%22The%20cat%20sat%20on%20the%20mat.%20The%20dog%20lay%20in%20the%20garden.%20Where%20is%20the%20dog%3F%5CnAnswer%3A%22%20-n%205%20-temp%200\">\n                            <button class=\"copy-button\" data-label=\"python run_inference.py -m models\/Llama3-8B-1.58-100B-tokens\/ggml-model-i2_s.gguf -p &quot;The cat sat on the mat. The dog lay in the garden. Where is the dog?\\nAnswer:&quot; -n 5 -temp 0\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>If everything is set up correctly, you should receive an output similar to:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-15\">The cat sat on the mat. The dog lay in the garden. Where is the dog?\nAnswer: The dog is in the garden.<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#The%20cat%20sat%20on%20the%20mat.%20The%20dog%20lay%20in%20the%20garden.%20Where%20is%20the%20dog%3F%0AAnswer%3A%20The%20dog%20is%20in%20the%20garden.\">\n                            <button class=\"copy-button\" data-label=\"The cat sat on the mat. The dog lay in the garden. Where is the dog?\nAnswer: The dog is in the garden.\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Advantages of BitNet<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Efficiency<\/strong>: Optimized for CPUs on Ubuntu, providing speed-ups and significant energy savings.<\/li>\n\n\n\n<li><strong>Scalable<\/strong>: Capable of running large models (e.g., 100 billion parameters) efficiently without requiring GPUs.<\/li>\n\n\n\n<li><strong>Open-Source<\/strong>: Customizable and extendable for various AI applications.<\/li>\n\n\n\n<li><strong>Versatile<\/strong>: Supports deployment on local servers or cloud-based Ubuntu systems.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Disadvantages of BitNet<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Limited Model Support<\/strong>: Only supports 1-bit quantized models; other models need conversion.<\/li>\n\n\n\n<li><strong>Complex Setup<\/strong>: Requires familiarity with Conda, CMake, and Python environments.<\/li>\n\n\n\n<li><strong>GPU Support<\/strong>: GPU and NPU support are planned for future versions but are not currently available.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Frequently Asked Questions (FAQ)<\/strong><\/h3>\n\n\n\n<p><strong>Q. What is 1-bit quantization in BitNet?<\/strong>\n\n\n\n<p>It\u2019s a technique that compresses model weights to a compact 1-bit format (1.58 bits per weight), making models faster and more energy-efficient.\n\n\n\n<p><strong>Q. Can I run BitNet on a cloud server?<\/strong>\n\n\n\n<p>Yes, BitNet can run on any Ubuntu system, whether local or cloud-based, as long as it meets the requirements.\n\n\n\n<p><strong>Q. Is GPU support available on Ubuntu?<\/strong>\n\n\n\n<p>Not yet. BitNet currently supports only CPU inference, with plans for GPU and NPU support in future releases.\n\n\n\n<p><strong>Q. Why is Conda recommended for the setup?<\/strong>\n\n\n\n<p>Conda isolates the environment, managing dependencies and preventing conflicts, ensuring a smooth setup process.\n\n\n\n<p><strong>Q. Do I need to install all dependencies manually?<\/strong>\n\n\n\n<p>The required dependencies can be installed using the provided script. Conda simplifies this by creating an isolated environment.\n\n\n\n<p><strong>Q. How do I update BitNet on Ubuntu?<\/strong>\n\n\n\n<p>Navigate to the BitNet directory and run:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-16\">git pull<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#git%20pull\">\n                            <button class=\"copy-button\" data-label=\"git pull\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p><br>Rebuild the project using the setup command.\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Important Points<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Always activate the Conda environment before running any BitNet commands (<code>conda activate bitnet-env<\/code>).<\/li>\n\n\n\n<li>Ensure all required dependencies (e.g., CMake, Clang) are correctly installed and configured.<\/li>\n\n\n\n<li>Follow updates from the repository closely to access new features like GPU support.<\/li>\n\n\n\n<li>Make sure you have sufficient system resources (CPU and RAM) to handle large models efficiently.<\/li>\n<\/ul>\n\n\n\n<p>By following these steps, you\u2019ll have BitNet up and running on your Ubuntu system, ready to leverage the power of 1-bit quantized large language models!\n","protected":false},"excerpt":{"rendered":"<p>BitNet is a powerful framework for running efficient AI models on your Ubuntu system using 1-bit quantization. This guide provides a quick installation process for [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":1340,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[248,247,18],"class_list":["post-1331","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-artificial-intelligence","tag-1-bit-quantization","tag-bitnet","tag-ubuntu"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/1331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/comments?post=1331"}],"version-history":[{"count":7,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/1331\/revisions"}],"predecessor-version":[{"id":1341,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/1331\/revisions\/1341"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media\/1340"}],"wp:attachment":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media?parent=1331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/categories?post=1331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/tags?post=1331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}