def cuda_postinstallation_actions()

in linux/cuda_installer/os_installers/__init__.py [0:0]


    def cuda_postinstallation_actions(self):
        """
        Perform required and suggested post-installation actions:
        * set environment variables
        * make persistent changes to environment variables
        * configure nvidia-persistanced to auto-start (if exists)

        More info: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions
        """
        os.environ["PATH"] = f"{CUDA_BIN_FOLDER}:{os.environ['PATH']}"
        if "LD_LIBRARY_PATH" in os.environ:
            os.environ["LD_LIBRARY_PATH"] = (
                f"{CUDA_LIB_FOLDER}:{os.environ['LD_LIBRARY_PATH']}"
            )
        else:
            os.environ["LD_LIBRARY_PATH"] = CUDA_LIB_FOLDER

        with CUDA_PROFILE_FILENAME.open("w") as profile:
            logger.info(f"Creating {CUDA_PROFILE_FILENAME} file...")
            profile.write(
                "# Configuring CUDA toolkit. File created by Google CUDA installation manager.\n"
            )
            profile.write("export PATH=" + CUDA_BIN_FOLDER + "${PATH:+:${PATH}}\n")
            profile.write(
                "export LD_LIBRARY_PATH="
                + CUDA_LIB_FOLDER
                + "${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}\n"
            )

        with open(self.BASHRC_PATH, mode="r+") as global_bashrc:
            logger.info(
                f"Updating {self.BASHRC_PATH} to source {CUDA_PROFILE_FILENAME}..."
            )
            content = global_bashrc.read()
            global_bashrc.seek(0)
            global_bashrc.write("\n# Enabling NVIDIA CUDA Toolkit\n")
            global_bashrc.write(f"source {CUDA_PROFILE_FILENAME}\n")
            global_bashrc.write(content)

        self.configure_persistanced_service()