Docker Nextcloud GPU support on Recognize

Hi all,

I love the Nextcloud project, I’ve been using it for over a year.

I want to add GPU (NVIDIA Quadro P2000) support to my docker Nextcloud install (Xeon E-1245 v5 64 GB RAM). My setup isn’t unusual, but I can’t find a decent tutorial. I’ve searched on the topic (a lot) and I’ve started with the official guide. After lots of trial and errors, I just a couple of hints to help me get started.

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Docker on Debian 11 (Portainer 2.21.2)
  • Web server and version (e.g, Apache 2.4.25):
    • nginx 1.27.3
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • nginx 1.27.3
  • PHP version (e.g, 8.3):
    • 8.2.26
  • Is this the first time you’ve seen this error? (Yes / No):
    • no
  • When did this problem seem to first start?
    • at installation
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Docker compose on Debian 11 (Proxmox VE)
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

From the official guide, when I try the pip install in my nextcloud-app container, I get this:

root@8cc087f08b1c:/# python3 -m pip install ‘tensorflow[and-cuda]’

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

Questions (yes, dumb ones):
1- Should I install Tensorflow in the Nextcloud container?
2- How can I check if Tensorflow is properly installed? Is there a command or a script available?

Configuration

Nextcloud

docker-compose.yml

volumes:
nextcloud:
db:
redis:
temp:

services:
db:
#image: mariadb:10.6
build: ‘./docker/mariadb’
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- db:/var/lib/mysql
- ./zzz.my.cnf:/etc/mysql/conf.d/zzz_zzz.my.cnf:ro
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=clouddb
- MYSQL_PASSWORD=clouddb
- MYSQL_DATABASE=nextclouddb
- MARIADB_AUTO_UPGRADE=1
- MARIADB_DISABLE_UPGRADE_BACKUP=1
env_file:
- zzz.db.env

redis:
image: redis:alpine
restart: always
volumes:
- redis:/data

app:
#image: nextcloud:fpm
build: ‘./docker/nextcloud’
restart: always
links:
- db
tmpfs:
- /tmp:exec
volumes:
- nextcloud:/var/www/html
- temp:/tmp_ssd
- /mnt/nextcloud/data:/data
- ./zzz.config.php:/usr/src/nextcloud/config/zzz_zzz.config.php:ro
- ./zzz.php.ini:/usr/local/etc/php/conf.d/zzz_zzz.php.ini:ro
environment:
- MYSQL_HOST=db
- MYSQL_USER=REMOVED
- MYSQL_PASSWORD=REMOVED
- MYSQL_DATABASE=nextclouddb
- REDIS_HOST=redis
- NEXTCLOUD_DATA_DIR=/data
- NEXTCLOUD_INIT_HTACCESS=true
- NEXTCLOUD_TRUSTED_DOMAINS=REMOVED
- PHP_MEMORY_LIMIT=8G
- PHP_UPLOAD_LIMIT=64G
env_file:
- zzz.db.env
depends_on:
- db
- redis

cron:
#image: nextcloud:fpm
build: ‘./docker/nextcloud’
restart: always
volumes:
- /mnt/nextcloud/data:/data
- nextcloud:/var/www/html:z
- ./zzz.cron.php:/var/www/html/cron.php:ro
entrypoint: /cron.sh
depends_on:
- db
- redis

web:
#image: nginx
build: ‘./docker/nginx’
restart: always
ports:
- 9002:80
links:
- app
volumes:
- ./zzz.nginx.conf:/etc/nginx/nginx.conf:ro
volumes_from:
- app
depends_on:
- app

occ config:list system

root@8cc087f08b1c:/var/www/html# sudo -u www-data php occ config:list system

{
“system”: {
“memcache.local”: “\OC\Memcache\APCu”,
“apps_paths”: [
{
“path”: “/var/www/html/apps”,
“url”: “/apps”,
“writable”: false
},
{
“path”: “/var/www/html/custom_apps”,
“url”: “/custom_apps”,
“writable”: true
}
],
“memcache.distributed”: “\OC\Memcache\Redis”,
“memcache.locking”: “\OC\Memcache\Redis”,
“redis”: {
“host”: “REMOVED SENSITIVE VALUE”,
“password”: “REMOVED SENSITIVE VALUE”,
“port”: 6379
},
“upgrade.disable-web”: true,
“default_language”: “en”,
“default_locale”: “en_CA”,
“default_phone_region”: “+1”,
“default_timezone”: “America/Montreal”,
“knowledgebaseenabled”: true,
“knowledgebase.embedded”: false,
“allow_user_to_change_display_name”: true,
“skeletondirectory”: “”,
“maintenance_window_start”: 20,
“overwriteprotocol”: “https”,
“overwrite.cli.url”: “REMOVED SENSITIVE VALUE”,
“htaccess.RewriteBase”: “/”,
“trashbin_retention_obligation”: “auto, 30”,
“tempdirectory”: “/tmp”,
“instanceid”: “REMOVED SENSITIVE VALUE”,
“passwordsalt”: “REMOVED SENSITIVE VALUE”,
“secret”: “REMOVED SENSITIVE VALUE”,
“trusted_domains”: [
REMOVED SENSITIVE VALUE
],
“datadirectory”: “REMOVED SENSITIVE VALUE”,
“dbtype”: “mysql”,
“version”: “30.0.2.2”,
“dbname”: “REMOVED SENSITIVE VALUE”,
“dbhost”: “REMOVED SENSITIVE VALUE”,
“dbport”: “”,
“dbtableprefix”: “oc_”,
“mysql.utf8mb4”: true,
“dbuser”: “REMOVED SENSITIVE VALUE”,
“dbpassword”: “REMOVED SENSITIVE VALUE”,
“installed”: true,
“maintenance”: false,
“memories.exiftool”: “/var/www/html/custom_apps/memories/bin-ext/exiftool-amd64-glibc”,
“memories.vod.path”: “/var/www/html/custom_apps/memories/bin-ext/go-vod-amd64”,
“enabledPreviewProviders”: [
“OC\Preview\HEIC”,
“OC\Preview\Image”,
“OC\Preview\TIFF”,
“OC\Preview\Movie”
],
“memories.gis_type”: 1,
“mysql.innodb_lock_wait_timeout”: “300”,
“forbidden_filename_basenames”: [
“con”,
“prn”,
“aux”,
“nul”,
“com0”,
“com1”,
“com2”,
“com3”,
“com4”,
“com5”,
“com6”,
“com7”,
“com8”,
“com9”,
“com\u00b9”,
“com\u00b2”,
“com\u00b3”,
“lpt0”,
“lpt1”,
“lpt2”,
“lpt3”,
“lpt4”,
“lpt5”,
“lpt6”,
“lpt7”,
“lpt8”,
“lpt9”,
“lpt\u00b9”,
“lpt\u00b2”,
“lpt\u00b3”
],
“forbidden_filename_characters”: [
“<”,
“>”,
“:”,
“"”,
“|”,
“?”,
“*”,
“\”,
“/”
],
“forbidden_filename_extensions”: [
" ",
“.”,
“.filepart”,
“.part”
]
}
}

Apps

root@8cc087f08b1c:/var/www/html# sudo -u www-data php occ app:list

Enabled:

  • app_api: 4.0.0
  • bruteforcesettings: 3.0.0
  • calendar: 5.0.8
  • circles: 30.0.0
  • cloud_federation_api: 1.13.0
  • comments: 1.20.1
  • contacts: 6.1.1
  • contactsinteraction: 1.11.0
  • dav: 1.31.1
  • federatedfilesharing: 1.20.0
  • federation: 1.20.0
  • files: 2.2.0
  • files_downloadlimit: 3.0.0
  • files_pdfviewer: 3.0.0
  • files_reminders: 1.3.0
  • files_sharing: 1.22.0
  • files_trashbin: 1.20.1
  • files_versions: 1.23.0
  • logreader: 3.0.0
  • lookup_server_connector: 1.18.0
  • memories: 7.4.1
  • notifications: 3.0.0
  • oauth2: 1.18.1
  • onlyoffice: 9.5.0
  • password_policy: 2.0.0
  • photos: 3.0.2
  • previewgenerator: 5.7.0
  • privacy: 2.0.0
  • provisioning_api: 1.20.0
  • recognize: 8.2.0
  • related_resources: 1.5.0
  • serverinfo: 2.0.0
  • settings: 1.13.0
  • sharebymail: 1.20.0
  • support: 2.0.0
  • text: 4.1.0
  • theming: 2.5.0
  • twofactor_backupcodes: 1.19.0
  • twofactor_nextcloud_notification: 4.0.0
  • twofactor_totp: 12.0.0-dev
  • updatenotification: 1.20.0
  • viewer: 3.0.0
  • workflowengine: 2.12.0
    Disabled:
  • activity: 3.0.0 (installed 3.0.0)
  • admin_audit: 1.20.0
  • dashboard: 7.10.0 (installed 7.10.0)
  • encryption: 2.18.0
  • files_external: 1.22.0
  • firstrunwizard: 3.0.0 (installed 3.0.0)
  • nextcloud_announcements: 2.0.0 (installed 2.0.0)
  • recommendations: 3.0.0 (installed 3.0.0)
  • richdocumentscode: 24.4.1002 (installed 24.4.1002)
  • survey_client: 2.0.0 (installed 2.0.0)
  • suspicious_login: 8.0.0
  • systemtags: 1.20.0 (installed 1.20.0)
  • user_ldap: 1.21.0
  • user_status: 1.10.0 (installed 1.10.0)
  • weather_status: 1.10.0 (installed 1.10.0)
  • webhook_listeners: 1.1.0-dev (installed 1.1.0-dev)

Thank you very much for your help!

Have wonderful holidays,
Cheers,

Hello,

This is little off topic, so please wait for someone with specific answer.

However, as far as I am aware, nextcloud or anything running in docker may not need any special modification to utilize the GPU. If the software is coded to take advantage of GPU acceleration, all one needs to do is to ensure the docker container is having access to the system GPU

I have JellyFin docker running with GPU based hardware acceleration.

This is the link you may need to follow to ensure the docker contains are having access to the host system GPU

Refer here for nVidia GPU → Installing the NVIDIA Container Toolkit — NVIDIA Container Toolkit 1.17.3 documentation

Thanks.

@NaXal That’s generally true, however, recognize is not explicitly built to run in docker (yet).

@gabidanpremier Since recognize will run in the nextcloud docker container, you will need to install tensorflow (and CUDA) in the Nextcloud container. Recognize’s admin settings should have indicators whether GPU is accessible.

1 Like