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
2b8ef455
Unverified
Commit
2b8ef455
authored
Sep 25, 2023
by
Michael Yang
Committed by
GitHub
Sep 25, 2023
Browse files
Merge pull request #593 from jmorganca/mxyng/install.sh
update install.sh
parents
1210db29
0c5f4717
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
scripts/install.sh
scripts/install.sh
+24
-13
No files found.
scripts/install.sh
View file @
2b8ef455
...
@@ -12,10 +12,11 @@ TEMP_DIR=$(mktemp -d)
...
@@ -12,10 +12,11 @@ TEMP_DIR=$(mktemp -d)
cleanup
()
{
rm
-rf
$TEMP_DIR
;
}
cleanup
()
{
rm
-rf
$TEMP_DIR
;
}
trap
cleanup EXIT
trap
cleanup EXIT
required_tools
()
{
available
()
{
command
-v
$1
>
/dev/null
;
}
require
()
{
local
MISSING
=
''
local
MISSING
=
''
for
TOOL
in
$*
;
do
for
TOOL
in
$*
;
do
if
!
command
-v
$TOOL
>
/dev/null
;
then
if
!
available
$TOOL
;
then
MISSING
=
"
$MISSING
$TOOL
"
MISSING
=
"
$MISSING
$TOOL
"
fi
fi
done
done
...
@@ -34,24 +35,24 @@ esac
...
@@ -34,24 +35,24 @@ esac
SUDO
=
SUDO
=
if
[
"
$(
id
-u
)
"
-ne
0
]
;
then
if
[
"
$(
id
-u
)
"
-ne
0
]
;
then
# Running as root, no need for sudo
# Running as root, no need for sudo
if
!
command
-v
sudo
>
/dev/null
;
then
if
!
available
sudo
;
then
error
"This script requires superuser permissions. Please re-run as root."
error
"This script requires superuser permissions. Please re-run as root."
fi
fi
SUDO
=
"sudo"
SUDO
=
"sudo"
fi
fi
MISSING_TOOL
S
=
$(
require
d_tools
curl
awk grep sed tee
xargs
)
NEED
S
=
$(
require curl
awk grep sed tee
xargs
)
if
[
-n
"
$
MISSING_TOOL
S
"
]
;
then
if
[
-n
"
$
NEED
S
"
]
;
then
status
"ERROR: The following tools are required but missing:"
status
"ERROR: The following tools are required but missing:"
for
MISSING_TOOL
in
$MISSING_TOOL
S
;
do
for
NEED
in
$NEED
S
;
do
echo
" -
$
MISSING_TOOL
"
echo
" -
$
NEED
"
done
done
exit
1
exit
1
fi
fi
status
"Downloading ollama..."
status
"Downloading ollama..."
$SUDO
curl
-
fsSL
-o
$TEMP_DIR
/ollama
"https://ollama.ai/download/ollama-linux-
$ARCH
"
$SUDO
curl
-
-fail
--show-error
--location
--progress-bar
-o
$TEMP_DIR
/ollama
"https://ollama.ai/download/ollama-linux-
$ARCH
"
status
"Installing ollama to /usr/bin..."
status
"Installing ollama to /usr/bin..."
$SUDO
install
-o0
-g0
-m755
-d
/usr/bin
$SUDO
install
-o0
-g0
-m755
-d
/usr/bin
...
@@ -96,15 +97,20 @@ EOF
...
@@ -96,15 +97,20 @@ EOF
esac
esac
}
}
if
command
-v
systemctl
>
/dev/nul
l
;
then
if
available systemct
l
;
then
configure_systemd
configure_systemd
fi
fi
if
!
available lspci
&&
!
available lshw
;
then
warning
"Unable to detect NVIDIA GPU. Install lspci or lshw to automatically detect and install NVIDIA CUDA drivers."
exit
0
fi
check_gpu
()
{
check_gpu
()
{
case
$1
in
case
$1
in
lspci
)
command
-v
lspci
>
/dev/null
&&
lspci
-d
'10de:'
|
grep
-q
'NVIDIA'
||
return
1
;;
lspci
)
available lspci
&&
lspci
-d
'10de:'
|
grep
-q
'NVIDIA'
||
return
1
;;
lshw
)
command
-v
lshw
>
/dev/null
&&
$SUDO
lshw
-c
display
-numeric
|
grep
-q
'vendor: .* \[10DE\]'
||
return
1
;;
lshw
)
available lshw
&&
$SUDO
lshw
-c
display
-numeric
|
grep
-q
'vendor: .* \[10DE\]'
||
return
1
;;
nvidia-smi
)
command
-v
nvidia-smi
>
/dev/null
||
return
1
;;
nvidia-smi
)
available
nvidia-smi
||
return
1
;;
esac
esac
}
}
...
@@ -178,7 +184,7 @@ OS_VERSION=$VERSION_ID
...
@@ -178,7 +184,7 @@ OS_VERSION=$VERSION_ID
PACKAGE_MANAGER
=
PACKAGE_MANAGER
=
for
PACKAGE_MANAGER
in
dnf yum apt-get
;
do
for
PACKAGE_MANAGER
in
dnf yum apt-get
;
do
if
command
-v
$PACKAGE_MANAGER
>
/dev/null
;
then
if
available
$PACKAGE_MANAGER
;
then
break
break
fi
fi
done
done
...
@@ -209,5 +215,10 @@ if ! lsmod | grep -q nvidia; then
...
@@ -209,5 +215,10 @@ if ! lsmod | grep -q nvidia; then
$SUDO
dkms
install
$NVIDIA_CUDA_VERSION
$SUDO
dkms
install
$NVIDIA_CUDA_VERSION
fi
fi
if
lsmod |
grep
-q
nouveau
;
then
status
"Removing nouveau..."
$SUDO
rmmod nouveau
fi
$SUDO
modprobe nvidia
$SUDO
modprobe nvidia
fi
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