LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-30-2015, 03:51 PM   #1
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys
Posts: 4,784

Rep: Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434
nvidia-persistenced and slack init


Greetings
I have 2 goals here

1) Immediate - Properly enable nvidia-persistenced daemon

2) Long Term - Understand Slackware init better

Info - I'm running Slackware v14.0 32 bit with GTX 760 on proprietary driver NVIDIA 352.41

This driver and many other newer ones has the ability to specify settings on a per user basis or globally. They provide a daemon, nvidia-persistenced, which is accompanied by 2 scripts, a make and script for the daemon and an init install script which searches for an init it understands, specifically SysV, systemd, and Upstart.

For SysV it naturally seeks /etc/init.d to install the start script. They provide a template as well as one generated for SysV, Below is the generatwed onwe from my system.

Code:
#!/bin/sh -e
#
# NVIDIA Persistence Daemon Init Script
#
# Copyright (c) 2013 NVIDIA Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# This is a sample System V init script, designed to show how the NVIDIA
# Persistence Daemon can be started.
#
# This sample does not rely on any init system functions, to ensure the
# widest portability possible.
#
# chkconfig: 2345 99 01
# description: Starts and stops the NVIDIA Persistence Daemon
# processname: nvidia-persistenced
#
### BEGIN INIT INFO
# Provides:         nvidia-persistenced
# Required-Start:   $ALL
# Required-Stop:    $ALL
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Description:      Starts and stops the NVIDIA Persistence Daemon
### END INIT INFO


NVPD=nvidia-persistenced
NVPD_BIN=/usr/bin/${NVPD}
NVPD_RUNTIME=/var/run/${NVPD}
NVPD_PIDFILE=${NVPD_RUNTIME}/${NVPD}.pid
NVPD_USER=nvidia-persistenced

if [ -f ${NVPD_PIDFILE} ]; then
  read -r NVPD_PID < "${NVPD_PIDFILE}"
  # Remove stale runtime files
  if [ "${NVPD_PID}" ] && [ ! -d /proc/${NVPD_PID} ]; then
    unset NVPD_PID
    rm -rf "${NVPD_RUNTIME}"
  fi
fi

case "${1}" in
  start)
      echo "Starting NVIDIA Persistence Daemon"

      # Execute the daemon as the intended user
      ${NVPD_BIN} --user ${NVPD_USER}
      ;;
  stop)
      echo "Stopping NVIDIA Persistence Daemon"

      # Stop the daemon - its PID should have been read in
      [ ! -z "${NVPD_PID}" ] && kill ${NVPD_PID} &> /dev/null
      ;;
  restart)
      $0 stop
      sleep 2
      $0 start
      ;;
  *) echo "usage: $0 {start|stop|restart}"
esac
exit 0
On my box /etc/init.d says it is a symlink to /etc/rc.d/init.d which does not exist, or didn't until today. Even when it didn't exist there were a few files in /etc/init.d but I'm quite certain they are of no consequence as 2 are text files, "functions" and "functions.README", and "vncserver.disabled".

So I created /etc/rc.d/init.d and copied the "nvidia-persistence.d" above to that directory. It does not work. The daemon is not started with the system.

Also included with the driver is an install script to install the executable "nvidia-persistence.d" to "/usr/bin" which I installed.

It seems to me I could just call the executable in any named init, such as rc.local but it would lack the start or stop confirmation messages.

So the problem is that there seem to be many ways to start this daemon and I'd like to know which is the proper "Slackware Way" as well as comments on whether or not it is a good idea to have /etc/rc.d/init.d for those apps that offer to use it properly?

Additionally nvidia-settings can create an nvidia-persistence.rc file which does a similar job. Any comments on best method much appreciated.
Thanks in advance
 
Old 09-30-2015, 06:39 PM   #2
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
You can always edit a sysv script to reference /etc/rc.d/init.d/functions for configuration. Otherwise, just edit the start/stop calls into rc.local/*_shutdown.

The script as-is looks compatible with Slackware's init anyway. Just start/stop it from rc.local/*_shutdown and test it.

Last edited by ReaperX7; 09-30-2015 at 06:41 PM.
 
Old 09-30-2015, 11:13 PM   #3
elcore
Senior Member
 
Registered: Sep 2014
Distribution: Slackware
Posts: 1,753

Rep: Reputation: Disabled
Is there a reason for using the daemon to enable persistence over nvidia-smi?
I just put "nvidia-smi -pm 1" in rc.local but I'd be interested if the daemon has any advantage.
 
Old 09-30-2015, 11:36 PM   #4
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
This explains it:

http://docs.nvidia.com/deploy/driver...nce/index.html
 
1 members found this post helpful.
Old 10-01-2015, 01:05 AM   #5
elcore
Senior Member
 
Registered: Sep 2014
Distribution: Slackware
Posts: 1,753

Rep: Reputation: Disabled
I have checked this out, install.sh fails because there is no chkconfig
Worked around this by editing this part:

Code:
    printf "  chkconfig found in PATH?  "
    $(which chkconfig >/dev/null 2>&1)
    if [ "$?" = "0" ]; then
        printf "Yes\n"
    else
        printf "No\n"
        sysv_supported=0
    fi
And simply switching sysv_supported=0 into sysv_supported=1
Also, this command further down the line tries to run chkconfig anyway, so I just remove that part:

Code:
    nvpdCommand "Enabling $sysv_script" \
                "chmod 0755 '$1/$sysv_script' && chkconfig --level 2345 $sysv_script on" \
Code:
    nvpdCommand "Enabling $sysv_script" \
                "chmod 0755 '$1/$sysv_script'" \
Installation:

Code:
sh install.sh -p /etc/rc.d/nvidia
Installs the script into /etc/rc.d/nvidia/nvidia-persistenced and creates the user/group nvidia-persistenced (999)
I declared this custom path intentionally, so I can start it from rc.local without it starting from someplace else automatically.
Got this in rc.local :

Code:
/etc/rc.d/nvidia/nvidia-persistenced start
/usr/bin/nvidia-persistenced --persistence-mode
And this in rc.local_shutdown :

Code:
/etc/rc.d/nvidia/nvidia-persistenced stop
So I can confirm it works and does what it's supposed to do, but I still prefer the "deprecated method"
 
Old 10-01-2015, 12:25 PM   #6
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
Make sure you rename nvidia-persistenced to an rc.* file if you install it to /etc/rc.d
 
Old 10-01-2015, 12:45 PM   #7
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys
Posts: 4,784

Original Poster
Rep: Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434Reputation: 4434
Thanks and kudos guys. Both my goals have been met. I have read extensively on the nvidia specific issue and don't know how I missed the section that ReaperX7 linked - very informative both short and long term. I am greatly indebted to you, elcore, since although I originally launched it from /etc/rc.d (and yes, I remembered to name it foo.rc) it left me with that "workaround feeling" and I happen to agree with your methodology completely. One should "never fold till it costs you to see the next hand". Thanks again. It is a major plus of Slackware that on top of being possibly the best, clear and simple distro, the community is top notch.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
broken apt + fail to boot w/ init: nvidia-persistenced Drone4four Ubuntu 14 12-25-2014 12:19 PM
Kernel Panic (init) with Slack and Grub Diademed Slackware 3 01-10-2006 06:02 PM
Audacity Init audio i/o error Slack 10 rhythmking Slackware 1 01-12-2005 01:43 PM
Slack 9.1 rc.inet2 init script azar92 Slackware 2 10-08-2003 06:41 PM
slack init scripts gui10 Slackware 11 05-15-2002 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration