How do I specify nvidia runtime from docker-compose.yml? - Stack Overflow (https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (Stack Overflow) (/opensearch.xml) (https://stackoverflow.com/questions/47465696/how-do-i-specify-nvidia-runtime-from-docker-compose-yml) (https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4) (https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=7d8876444382) (Feed for question 'How do I specify nvidia runtime from docker-compose.yml?') (/feeds/question/47465696) (https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7) (https://accounts.google.com/gsi/style) (site logo) Join Stack Overflow By clicking “Sign up”, you agree to our (/legal/terms-of-service/public) terms of service and acknowledge you have read our (/legal/privacy-policy) privacy policy . (9b9d1ff1208457cf29de4d03e17fc06b55f301e0c5c48e7398c73e63b318268a) (1) (2.0) Sign up with Google Sign up with GitHub OR (9b9d1ff1208457cf29de4d03e17fc06b55f301e0c5c48e7398c73e63b318268a) (1) () () () () () () Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (/users/login) Log in (9b9d1ff1208457cf29de4d03e17fc06b55f301e0c5c48e7398c73e63b318268a) () Skip to main content (https://stackoverflow.com) Stack Overflow (https://stackoverflow.co/) About Products (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai) OverflowAI (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai) OverflowAI GenAI features for Teams (https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) OverflowAPI Train & fine-tune LLMs (https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs) Labs The future of collective knowledge sharing (https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) About the company (https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) Visit the blog (Search…) () Loading… (https://stackoverflow.com) current community (https://stackoverflow.com) (Stack Overflow) Stack Overflow (https://stackoverflow.com/help) help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) chat (https://meta.stackoverflow.com) (Meta Stack Overflow) Meta Stack Overflow your communities (https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47465696%2fhow-do-i-specify-nvidia-runtime-from-docker-compose-yml) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47465696%2fhow-do-i-specify-nvidia-runtime-from-docker-compose-yml) log in to customize your list. (https://stackexchange.com/sites) more stack exchange communities (https://stackoverflow.blog) company blog (Click to show search) (https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47465696%2fhow-do-i-specify-nvidia-runtime-from-docker-compose-yml) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47465696%2fhow-do-i-specify-nvidia-runtime-from-docker-compose-yml) Sign up Let's set up your homepage Select a few topics you're interested in: python javascript c# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: (Search) javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json python-3.x .net ruby-on-rails sql-server swift django angular objective-c excel pandas angularjs regex typescript ruby linux ajax iphone vba xml laravel spring asp.net-mvc database wordpress string flutter postgresql mongodb wpf windows amazon-web-services xcode bash git oracle-database spring-boot dataframe azure firebase list multithreading docker vb.net react-native eclipse algorithm powershell macos visual-studio numpy image forms scala function vue.js performance twitter-bootstrap selenium winforms kotlin loops express dart hibernate sqlite matlab python-2.7 shell rest apache entity-framework android-studio csv maven api linq qt dictionary unit-testing facebook asp.net-core tensorflow apache-spark file swing class unity-game-engine sorting date authentication go symfony t-sql opencv matplotlib .htaccess google-chrome for-loop datetime codeigniter http perl validation sockets google-maps object uitableview xaml oop if-statement visual-studio-code cordova ubuntu web-services email android-layout github elasticsearch spring-mvc kubernetes selenium-webdriver ms-access user-interface parsing ggplot2 pointers machine-learning google-sheets c++11 security flask google-apps-script ruby-on-rails-3 templates nginx variables exception sql-server-2008 gradle debugging tkinter listview delphi jpa asynchronous pdf web-scraping haskell jsp ssl amazon-s3 google-cloud-platform jenkins testing xamarin wcf npm batch-file generics ionic-framework network-programming unix recursion google-app-engine mongoose visual-studio-2010 .net-core android-fragments assembly animation math next.js session svg hadoop intellij-idea curl django-models join laravel-5 rust winapi url heroku http-redirect tomcat google-cloud-firestore inheritance webpack keras image-processing gcc asp.net-mvc-4 web logging dom swiftui matrix pyspark actionscript-3 button post optimization firebase-realtime-database jquery-ui iis cocoa xpath d3.js javafx firefox internet-explorer xslt caching select asp.net-mvc-3 opengl events asp.net-web-api plot dplyr magento encryption search stored-procedures amazon-ec2 ruby-on-rails-4 memory canvas audio multidimensional-array jsf random vector cookies redux facebook-graph-api input flash xamarin.forms indexing arraylist ipad cocoa-touch data-structures video apache-kafka model-view-controller serialization jdbc woocommerce routes razor azure-devops awk servlets mod-rewrite beautifulsoup docker-compose excel-formula iframe filter aws-lambda design-patterns text django-rest-framework visual-c++ cakephp mobile android-intent react-hooks struct methods groovy mvvm ssh lambda checkbox ecmascript-6 google-chrome-extension time grails installation sharepoint cmake shiny spring-security jakarta-ee android-recyclerview plsql core-data types meteor android-activity sed bootstrap-4 websocket activerecord graph replace scikit-learn file-upload group-by vim junit boost deep-learning import sass memory-management error-handling async-await dynamic eloquent soap silverlight dependency-injection charts layout apache-spark-sql deployment browser gridview svn while-loop google-bigquery vuejs2 ffmpeg dll highcharts view foreach plugins makefile c#-4.0 redis reporting-services jupyter-notebook merge server unicode https reflection google-maps-api-3 twitter oauth-2.0 extjs pytorch axios terminal pip split mysqli cmd django-views encoding database-design automation collections netbeans hash build data-binding ember.js tcp sqlalchemy pdo apache-flex concurrency entity-framework-core command-line spring-data-jpa printing java-8 react-redux jestjs service html-table neo4j lua ansible parameters module material-ui enums visual-studio-2012 promise flexbox outlook webview firebase-authentication web-applications uwp jquery-mobile utf-8 datatable python-requests parallel-processing drop-down-menu colors scroll hive tfs scipy count syntax ms-word twitter-bootstrap-3 ssis google-analytics fonts three.js constructor powerbi rxjs graphql file-io paypal discord cassandra socket.io graphics compiler-errors gwt react-router nlp solr url-rewriting backbone.js memory-leaks datatables oauth datagridview terraform drupal oracle11g zend-framework neural-network knockout.js triggers django-forms interface google-api angular-material casting jmeter linked-list path proxy timer django-templates arduino orm directory visual-studio-2015 parse-platform windows-phone-7 cron push-notification conditional-statements primefaces functional-programming pagination model jar xamarin.android hyperlink uiview visual-studio-2013 gitlab vbscript google-cloud-functions azure-active-directory jwt download swift3 sql-server-2005 configuration process rspec pygame properties combobox callback windows-phone-8 linux-kernel safari permissions scrapy raspberry-pi scripting emacs clojure x86 scope io compilation mongodb-query nhibernate responsive-design angularjs-directive expo request azure-functions bluetooth 3d dns binding reference discord.js architecture playframework version-control pyqt doctrine-orm package pycharm get sql-server-2012 rubygems f# autocomplete datepicker openssl kendo-ui tree jackson controller yii grep nested xamarin.ios static dockerfile statistics transactions datagrid null active-directory uiviewcontroller phpmyadmin webforms discord.py notifications sas computer-vision duplicates mocking youtube nullpointerexception yaml menu sum bitmap electron asp.net-mvc-5 visual-studio-2008 time-series blazor yii2 jsf-2 css-selectors stl android-listview floating-point cryptography ant stream hashmap character-encoding msbuild sdk asp.net-core-mvc google-drive-api selenium-chromedriver jboss joomla navigation cors devise anaconda background camera multiprocessing pyqt5 binary frontend cuda linq-to-sql iterator mariadb onclick plotly ios7 rabbitmq android-jetpack-compose android-asynctask microsoft-graph-api tabs laravel-4 insert uicollectionview environment-variables amazon-dynamodb linker console xsd coldfusion upload continuous-integration ftp textview opengl-es operating-system vuejs3 mockito localization xml-parsing macros formatting json.net kivy type-conversion data.table timestamp calendar integer segmentation-fault android-ndk drag-and-drop prolog char crash jasmine automated-tests dependencies geometry android-gradle-plugin itext firebase-cloud-messaging header fortran sprite-kit mfc attributes nuxt.js nosql format azure-pipelines nestjs odoo jquery-plugins db2 jenkins-pipeline leaflet event-handling postman flutter-layout julia annotations keyboard textbox arm visual-studio-2017 gulp libgdx stripe-payments xampp synchronization crystal-reports timezone dom-events azure-web-app-service android-emulator uikit swagger wso2 sequelize.js namespaces aggregation-framework uiscrollview jvm google-sheets-formula chart.js com subprocess geolocation webdriver centos html5-canvas widget dialog garbage-collection snowflake-cloud-data-platform numbers concatenation sql-update qml set windows-10 mapreduce tuples smtp ionic2 java-stream rotation modal-dialog spring-data android-edittext http-headers doctrine radio-button nuget grid sonarqube lucene xmlhttprequest internationalization listbox components initialization switch-statement google-play apache-camel boolean serial-port ldap ios5 youtube-api return gdb pivot eclipse-plugin latex frameworks tags containers github-actions dataset asp-classic subquery foreign-keys label copy uinavigationcontroller c++17 delegates google-cloud-storage struts2 migration base64 protractor find sql-server-2008-r2 queue uibutton embedded arguments composer-php append jaxb zip stack cucumber autolayout ide entity-framework-6 popup iteration airflow windows-7 r-markdown ssl-certificate vb6 tailwind-css gmail hover jqgrid g++ udp Next You’ll be prompted to create an account to view your personalized homepage. (/) Home (/questions) Questions (/tags) Tags (/users) Users (https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) Companies Labs (/jobs?source=so-left-nav) Jobs (/beta/discussions) Discussions Collectives Communities for your favorite technologies. (/collectives-all) Explore all Collectives Teams () Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. (/collectives) Learn more about Collectives Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. (https://stackoverflow.co/teams/) Learn more about Teams Get early access and see previews of new features. (https://stackoverflow.co/labs/) Learn more about Labs (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (/questions/47465696/how-do-i-specify-nvidia-runtime-from-docker-compose-yml) How do I specify nvidia runtime from docker-compose.yml? (/questions/ask) Ask Question (2017-11-24 02:51:53Z) Asked 7 years, 3 months ago Modified (?lastactivity) (2024-03-27 08:09:30Z) 11 months ago (Viewed 53,532 times) Viewed 54k times This question shows research effort; it is useful and clear (70:3:31e,16:d1d3bb4927a7eac3,10:1742105113,16:2dbd3d6d997c3220,8:47465696,7aa31316955d256255d25592141d2fcb7ca29bad7a5270a26edaf52d6591185b) 43 (This question does not show any research effort; it is unclear or not useful) (70:3:31e,16:f4b1fd5160d722fb,10:1742105113,16:d6bf083e4c12f654,8:47465696,5b038f356cb772e9132bffa12e7d8548a002aeb6bbd1942ac7910e6aa2d560d2) Save this question. (/posts/47465696/timeline) Show activity on this post. I am able to run a tensorflow container w/ access to the GPU from the command line w/ the following command $ sudo docker run --runtime=nvidia --rm gcr.io/tensorflow/tensorflow:latest-gpu I would like to be able to run this container from docker-compose. Is it possible to specify the --runtime flag from docker-compose.yml ? (/questions/tagged/docker) (show questions tagged 'docker') docker (/questions/tagged/docker-compose) (show questions tagged 'docker-compose') docker-compose (/questions/tagged/tensorflow) (show questions tagged 'tensorflow') tensorflow (/questions/tagged/nvidia-docker) (show questions tagged 'nvidia-docker') nvidia-docker (/q/47465696) (Short permalink to this question) Share Share a link to this question Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/47465696/edit) () Improve this question Follow (70:3:31e,16:44ab79a9a5657aba,10:1742105113,16:ef269d401ebea5e1,8:47465696,720b6d6a6bde642dae78df9a1620556ac3cb6bef4a1f5ce4d825b5c7dc3493ee) Follow this question to receive notifications asked (2017-11-24 02:51:53Z) Nov 24, 2017 at 2:51 (/users/2313424/rissem) (rissem's user avatar) (/users/2313424/rissem) rissem rissem (reputation score) 553 (1 gold badge) 1 1 gold badge (5 silver badges) 5 5 silver badges (11 bronze badges) 11 11 bronze badges (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) Add a comment | (Expand to show all comments on this post) 4 Answers 4 Sorted by: (/questions/47465696/how-do-i-specify-nvidia-runtime-from-docker-compose-yml?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (trending) Trending (recent votes count more) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful (70:3:31e,16:9ac5ac5314908815,10:1742105113,16:2d0800bec1fe0ba6,8:52063921,fc6527e6fdb33bbe79b473c8eca99d20912808634a2f029ab5d0471cef9493d2) 52 (This answer is not useful) (70:3:31e,16:504f4cc054b5dd03,10:1742105113,16:0e8de37d3a415cf6,8:52063921,abb44c2221b1db700adcfdf9e438a79c4bf018aa09cbaead8145aa3e48decf2a) Save this answer. (Loading when this answer was accepted…) (/posts/52063921/timeline) Show activity on this post. Currently (Aug 2018), NVIDIA container runtime for Docker ((https://github.com/NVIDIA/nvidia-docker) nvidia-docker2 ) (https://github.com/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#do-you-support-docker-compose) supports Docker Compose . Yes, use Compose format 2.3 and add runtime: nvidia to your GPU service. Docker Compose must be version 1.19.0 or higher. Example docker-compose.yml : version: '2.3' services: nvsmi: image: ubuntu:16.04 runtime: nvidia environment: - NVIDIA_VISIBLE_DEVICES=all command: nvidia-smi More (https://devblogs.nvidia.com/gpu-containers-runtime/) example from NVIDIA blog uses Docker Compose to show how to launch multiple GPU containers with the NVIDIA Container Runtime. (/a/52063921) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/52063921/edit) () Improve this answer Follow (70:3:31e,16:8a307b00d2545cb4,10:1742105113,16:b7544b24b0b9a1fd,8:52063921,b8210daa17561fd7c1fdaf643b6cf0d80b4336051efc4396937f96dd0be2681d) Follow this answer to receive notifications answered (2018-08-28 18:04:47Z) Aug 28, 2018 at 18:04 (/users/206570/cedrickchee) (cedrickchee's user avatar) (/users/206570/cedrickchee) cedrickchee cedrickchee (reputation score) 902 (8 silver badges) 8 8 silver badges (12 bronze badges) 12 12 bronze badges 4 (number of 'useful comment' votes received) 5 This option is possible only for docker-compose v2 for now. For more info, please look at the corresponding pull request here (https://github.com/docker/compose/pull/5405) github.com/docker/compose/pull/5405 – (/users/5893031/hgasimov) (156 reputation) hgasimov Commented (2018-12-30 09:33:31Z, License: CC BY-SA 4.0) Dec 30, 2018 at 9:33 (this comment was edited 1 time) This option is more elegant as it allows for better packaging using docker-compose – (/users/1639453/blaze) (1,722 reputation) Blaze Commented (2019-01-22 08:13:11Z, License: CC BY-SA 4.0) Jan 22, 2019 at 8:13 hm can different containers have different runtimes in one docker-compose file? – (/users/1346212/kodlan) (631 reputation) kodlan Commented (2021-02-01 20:59:12Z, License: CC BY-SA 4.0) Feb 1, 2021 at 20:59 Do I still have to include the nvidia runtime in the deamon.json? – (/users/5719743/marcel) (131 reputation) Marcel Commented (2024-09-23 13:23:08Z, License: CC BY-SA 4.0) Sep 23, 2024 at 13:23 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (70:3:31e,16:7217458f79ec654c,10:1742105113,16:a441f94d7e1e7e65,8:47495905,b6e95805c8d93b2f090d8f4ce7befcc69717d4641298bd30cbe915e3ee8ca638) 32 (This answer is not useful) (70:3:31e,16:c114889ac4706847,10:1742105113,16:a121d306c3438586,8:47495905,134170a9ebe5f472864de6f7a142a7a3f79239c8e94dc71e72bbc6a1b9a4ea55) Save this answer. (Loading when this answer was accepted…) (/posts/47495905/timeline) Show activity on this post. You should edit /etc/docker/daemon.json , adding the first level key "default-runtime": "nvidia" , restart docker daemon (ex. "sudo service docker restart" ) and then all containers on that host will run with nvidia runtime. More info on daemon.json (https://docs.docker.com/engine/reference/commandline/dockerd/) here (/a/47495905) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/47495905/edit) () Improve this answer Follow (70:3:31e,16:fd9da5e9250ecb54,10:1742105113,16:18e6546e18eaca1b,8:47495905,d7b11ea40de08a5068dc5bb851103ed47a61faf5faf5356f4e8519063abc0c24) Follow this answer to receive notifications answered (2017-11-26 11:58:57Z) Nov 26, 2017 at 11:58 (/users/1694635/gabriel-miretti-aka-gmiretti) (Gabriel Miretti aka gmiretti's user avatar) (/users/1694635/gabriel-miretti-aka-gmiretti) Gabriel Miretti aka gmiretti Gabriel Miretti aka gmiretti (reputation score) 1,469 (13 silver badges) 13 13 silver badges (16 bronze badges) 16 16 bronze badges (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (70:3:31e,16:5506659f722b20a4,10:1742105113,16:cc78d8c177ee2641,8:51457260,ef85d22a567453bc6dad48e9e7521284782229dfdac1ca0d4ff6a92bd924b717) 5 (This answer is not useful) (70:3:31e,16:09f24d0192af7a06,10:1742105113,16:ea60a8f9e956c276,8:51457260,e4820defdffff59a316c31540a82efd75725faaf96893390e4a5407986585d2a) Save this answer. (Loading when this answer was accepted…) (/posts/51457260/timeline) Show activity on this post. Or better: using systemd and assuming the path is /usr/libexec/oci/hooks.d/nvidia Configure mkdir -p /etc/systemd/system/docker.service.d/ cat > /etc/systemd/system/docker.service.d/nvidia-containers.conf <