Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
e29662ab
Commit
e29662ab
authored
Sep 23, 2023
by
Jeffrey Morgan
Browse files
fix minor install script issues on debian
parent
cbc40aa9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
24 deletions
+26
-24
scripts/install.sh
scripts/install.sh
+26
-24
No files found.
scripts/install.sh
View file @
e29662ab
...
...
@@ -30,12 +30,14 @@ case "$(uname -m)" in
*
)
error
"Unsupported architecture:
$ARCH
"
;;
esac
SUDO
_CMD
=
SUDO
=
if
[
"
$(
id
-u
)
"
-ne
0
]
;
then
# Running as root, no need for sudo
if
!
command
-v
sudo
>
/dev/null
;
then
error
"Ollama install.sh requires elevated privileges. Please re-run as root."
fi
SUDO
=
"sudo"
fi
MISSING_TOOLS
=
$(
required_tools curl
awk grep sed tee
xargs
)
...
...
@@ -44,11 +46,11 @@ if [ -n "$MISSING_TOOLS" ]; then
fi
status
"Downloading ollama..."
$SUDO
_CMD
curl
-fsSL
-o
$TEMP_DIR
/ollama
"https://ollama.ai/download/ollama-linux-
$ARCH
"
$SUDO
curl
-fsSL
-o
$TEMP_DIR
/ollama
"https://ollama.ai/download/ollama-linux-
$ARCH
"
status
"Installing ollama to /usr/bin..."
$SUDO
_CMD
install
-o0
-g0
-m755
-d
/usr/bin
$SUDO
_CMD
install
-o0
-g0
-m755
$TEMP_DIR
/ollama /usr/bin/ollama
$SUDO
install
-o0
-g0
-m755
-d
/usr/bin
$SUDO
install
-o0
-g0
-m755
$TEMP_DIR
/ollama /usr/bin/ollama
install_success
()
{
status
'Install complete. Run "ollama" from the command line.'
;
}
trap
install_success EXIT
...
...
@@ -58,11 +60,11 @@ trap install_success EXIT
configure_systemd
()
{
if
!
id
ollama
>
/dev/null 2>&1
;
then
status
"Creating ollama user..."
$SUDO
_CMD
useradd
-r
-s
/bin/false
-m
-d
/usr/share/ollama ollama
$SUDO
useradd
-r
-s
/bin/false
-m
-d
/usr/share/ollama ollama
fi
status
"Creating ollama systemd service..."
cat
<<
EOF
|
$SUDO
_CMD
tee /etc/systemd/system/ollama.service >/dev/null
cat
<<
EOF
|
$SUDO
tee /etc/systemd/system/ollama.service >/dev/null
[Unit]
Description=Ollama Service
After=network-online.target
...
...
@@ -80,9 +82,9 @@ WantedBy=default.target
EOF
if
[
"
$(
systemctl is-system-running
||
echo
'not running'
)
"
=
'running'
]
;
then
status
"Enabling and starting ollama service..."
$SUDO
_CMD
systemctl daemon-reload
$SUDO
_CMD
systemctl
enable
ollama
$SUDO
_CMD
systemctl restart ollama
$SUDO
systemctl daemon-reload
$SUDO
systemctl
enable
ollama
$SUDO
systemctl restart ollama
fi
}
...
...
@@ -111,11 +113,11 @@ install_cuda_driver_yum() {
status
'Installing NVIDIA repository...'
case
$PACKAGE_MANAGER
in
yum
)
$SUDO
_CMD
$PACKAGE_MANAGER
-y
install
yum-utils
$SUDO
_CMD
$PACKAGE_MANAGER
-config-manager
--add-repo
https://developer.download.nvidia.com/compute/cuda/repos/
$1$2
/
$(
uname
-m
)
/cuda-
$1$2
.repo
$SUDO
$PACKAGE_MANAGER
-y
install
yum-utils
$SUDO
$PACKAGE_MANAGER
-config-manager
--add-repo
https://developer.download.nvidia.com/compute/cuda/repos/
$1$2
/
$(
uname
-m
)
/cuda-
$1$2
.repo
;;
dnf
)
$SUDO
_CMD
dnf config-manager
--add-repo
https://developer.download.nvidia.com/compute/cuda/repos/
$1$2
/
$(
uname
-m
)
/cuda-
$1$2
.repo
$SUDO
dnf config-manager
--add-repo
https://developer.download.nvidia.com/compute/cuda/repos/
$1$2
/
$(
uname
-m
)
/cuda-
$1$2
.repo
;;
esac
...
...
@@ -123,16 +125,16 @@ install_cuda_driver_yum() {
rhel
)
status
'Installing EPEL repository...'
# EPEL is required for third-party dependencies such as dkms and libvdpau
$SUDO
_CMD
$PACKAGE_MANAGER
-y
install
https://dl.fedoraproject.org/pub/epel/epel-release-latest-
$2
.noarch.rpm
$SUDO
$PACKAGE_MANAGER
-y
install
https://dl.fedoraproject.org/pub/epel/epel-release-latest-
$2
.noarch.rpm
;;
esac
status
'Installing CUDA driver...'
$SUDO
_CMD
$PACKAGE_MANAGER
-y
update
$SUDO
_CMD
$PACKAGE_MANAGER
-y
install
cuda-drivers
$SUDO
$PACKAGE_MANAGER
-y
update
$SUDO
$PACKAGE_MANAGER
-y
install
cuda-drivers
if
[
"
$1
"
=
'centos'
]
||
[
"
$1$2
"
=
'rhel7'
]
;
then
$SUDO
_CMD
$PACKAGE_MANAGER
-y
install
nvidia-driver-latest-dkms
$SUDO
$PACKAGE_MANAGER
-y
install
nvidia-driver-latest-dkms
fi
}
...
...
@@ -145,14 +147,14 @@ install_cuda_driver_apt() {
case
$1
in
debian
)
status
'Enabling contrib sources...'
sed
's/main/contrib/'
</etc/apt/sources.list
>
/etc/apt/sources.list.d/contrib.list
$SUDO
sed
's/main/contrib/'
<
/etc/apt/sources.list
|
sudo tee
/etc/apt/sources.list.d/contrib.list
>
/dev/null
;;
esac
status
'Installing CUDA driver...'
$SUDO
_CMD
dpkg
-i
$TEMP_DIR
/cuda-keyring.deb
$SUDO
_CMD
apt-get update
$SUDO
_CMD
apt-get
-y
install
cuda-drivers
$SUDO
dpkg
-i
$TEMP_DIR
/cuda-keyring.deb
$SUDO
apt-get update
DEBIAN_FRONTEND
=
noninteractive
$SUDO
apt-get
-y
install
cuda-drivers
-q
}
if
[
!
-f
"/etc/os-release"
]
;
then
...
...
@@ -187,10 +189,10 @@ fi
if
!
lsmod |
grep
-q
nvidia
;
then
KERNEL_RELEASE
=
"
$(
uname
-r
)
"
case
$OS_NAME
in
centos|rhel|rocky|fedora
)
$SUDO
_CMD
$PACKAGE_MANAGER
-y
install
kernel-devel-
$KERNEL_RELEASE
kernel-headers-
$KERNEL_RELEASE
;;
debian|ubuntu
)
$SUDO
_CMD
apt-get
-y
install
linux-headers-
$KERNEL_RELEASE
;;
centos|rhel|rocky|fedora
)
$SUDO
$PACKAGE_MANAGER
-y
install
kernel-devel-
$KERNEL_RELEASE
kernel-headers-
$KERNEL_RELEASE
;;
debian|ubuntu
)
$SUDO
apt-get
-y
install
linux-headers-
$KERNEL_RELEASE
;;
esac
$SUDO
_CMD
dkms status |
awk
-F
:
'/added/ { print $1 }'
| xargs
-n1
$SUDO
_CMD
dkms
install
$SUDO
_CMD
modprobe nvidia
$SUDO
dkms status |
awk
-F
:
'/added/ { print $1 }'
| xargs
-n1
$SUDO
dkms
install
$SUDO
modprobe nvidia
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment