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
efac4886
Commit
efac4886
authored
Jun 03, 2024
by
Daniel Hiltgen
Browse files
Revert "Limit GPU lib search for now (#4777)"
This reverts commit
476fb8e8
.
parent
4dc7fb95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
gpu/gpu.go
gpu/gpu.go
+31
-1
No files found.
gpu/gpu.go
View file @
efac4886
...
...
@@ -16,12 +16,13 @@ import (
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"unsafe"
"github.com/ollama/ollama/envconfig"
"github.com/ollama/ollama/format"
"github.com/ollama/ollama/envconfig"
)
type
handles
struct
{
...
...
@@ -104,6 +105,8 @@ func initGPUHandles() *handles {
var
cudartMgmtPatterns
[]
string
var
nvcudaMgmtName
string
var
nvcudaMgmtPatterns
[]
string
var
oneapiMgmtName
string
var
oneapiMgmtPatterns
[]
string
tmpDir
,
_
:=
PayloadsDir
()
switch
runtime
.
GOOS
{
...
...
@@ -115,6 +118,8 @@ func initGPUHandles() *handles {
// Aligned with driver, we can't carry as payloads
nvcudaMgmtName
=
"nvcuda.dll"
nvcudaMgmtPatterns
=
NvcudaWindowsGlobs
oneapiMgmtName
=
"ze_intel_gpu64.dll"
oneapiMgmtPatterns
=
OneapiWindowsGlobs
case
"linux"
:
cudartMgmtName
=
"libcudart.so*"
if
tmpDir
!=
""
{
...
...
@@ -125,6 +130,8 @@ func initGPUHandles() *handles {
// Aligned with driver, we can't carry as payloads
nvcudaMgmtName
=
"libcuda.so*"
nvcudaMgmtPatterns
=
NvcudaLinuxGlobs
oneapiMgmtName
=
"libze_intel_gpu.so"
oneapiMgmtPatterns
=
OneapiLinuxGlobs
default
:
return
gpuHandles
}
...
...
@@ -152,6 +159,17 @@ func initGPUHandles() *handles {
}
}
oneapiLibPaths
:=
FindGPULibs
(
oneapiMgmtName
,
oneapiMgmtPatterns
)
if
len
(
oneapiLibPaths
)
>
0
{
deviceCount
,
oneapi
,
libPath
:=
LoadOneapiMgmt
(
oneapiLibPaths
)
if
oneapi
!=
nil
{
slog
.
Debug
(
"detected Intel GPUs"
,
"library"
,
libPath
,
"count"
,
deviceCount
)
gpuHandles
.
oneapi
=
oneapi
gpuHandles
.
deviceCount
=
deviceCount
return
gpuHandles
}
}
return
gpuHandles
}
...
...
@@ -227,6 +245,18 @@ func GetGPUInfo() GpuInfoList {
// TODO potentially sort on our own algorithm instead of what the underlying GPU library does...
resp
=
append
(
resp
,
gpuInfo
)
}
if
gpuHandles
.
oneapi
!=
nil
{
gpuInfo
:=
GpuInfo
{
Library
:
"oneapi"
,
}
C
.
oneapi_check_vram
(
*
gpuHandles
.
oneapi
,
&
memInfo
)
var
totalFreeMem
float64
=
float64
(
memInfo
.
free
)
*
0.95
// work-around: leave some reserve vram for mkl lib used in ggml-sycl backend.
memInfo
.
free
=
C
.
uint64_t
(
totalFreeMem
)
gpuInfo
.
TotalMemory
=
uint64
(
memInfo
.
total
)
gpuInfo
.
FreeMemory
=
uint64
(
memInfo
.
free
)
gpuInfo
.
ID
=
strconv
.
Itoa
(
i
)
resp
=
append
(
resp
,
gpuInfo
)
}
}
// Then AMD
...
...
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