Esempio n. 1
0
	def __del__(self):
		logger.close()
		if self.tmpdir:
			if not settings['upload_dir']:
				print "No upload_dir, examining."
				self.examine(self.tmpdir)
			print "Removing " + self.tmpdir
			return shutil.rmtree(self.tmpdir)
Esempio n. 2
0
        min_loss = float(var2num(torch.min(losses)))
        max_loss = float(var2num(torch.max(losses)))
        mean_loss = float(var2num(loss_mean))
        #        log.write("emb", var2num(endpoints["emb"]), dtype=np.float32)
        log.write("pids", var2num(target), dtype=np.int)
        log.write("file", path, dtype=h5py.special_dtype(vlen=str))
        #log.write("log", [min_loss, mean_loss, max_loss, lr, topks[0], topks[4]], np.float32)
        optimizer.zero_grad()
        loss_mean.backward()
        optimizer.step()

        #log.write("batch_norm", var2num(model.module.batch_norm.running_mean))
        took = time.time() - start_time
        # print("batch {} loss: {:.3f}|{:.3f}|{:.3f} lr: {:.6f} "
        #       "top1: {:.3f} top5: {:.3f} | took {:.3f}s".format(
        #     t, min_loss, mean_loss, max_loss, lr,
        #     topks[0], topks[4], took
        #     ))
        print("batch {} loss: {:.3f}|{:.3f}|{:.3f} "
              "top1: {:.3f} top5: {:.3f} | took {:.3f}s".format(
                  t, min_loss, mean_loss, max_loss, topks[0], topks[4], took))
        t += 1
        if t % args.checkpoint_frequency == 0:
            log.save_model_state(model, t)
        if t >= t1:
            break
log.save_model_state(model, t)
log.close()

print("Finished Training! Took: {:.3f}".format(time.time() - overall_time))
Esempio n. 3
0
     ( )
      H
      H
     _H_
  .-'-.-'-.
 /         \\       ####   ####   #####  #   #  #####  ####   #   #
|           |      #   #  #   #  #      #   #  #      #   #  #   #
|   .-------'._    ####   ####   ###    # # #  ###    ####    # #
|  / /  '.' '. \\   #   #  #  #   #      # # #  #      #  #     #
|  \\ \\ @   @ / /   ####   #   #  #####   # #   #####  #   #    #
|   '---------'
|    _______|                       = 2014 =
|  .'-+-+-+|
|  '.-+-+-+|
|    """""" |
'-.__   __.-'
     """''')

    import eventloop
    import logger
    import leds

    logger.initialize(args)

    loop = eventloop.EventLoop(args.statemachine, args.webserver_port, not args.disable_interbot)
    leds.initialize(loop)
    loop.start()
    logger.close()

    sys.exit(loop.exit_value)
Esempio n. 4
0
 def __exit__(self, type, value, traceback):
     logger.close()
     del os.environ['__DCGM_TESTING_FRAMEWORK_ACTIVE']
     pass
Esempio n. 5
0
    def __enter__(self):
        '''Initialize the test framework or exit on failure'''

        os.environ['__DCGM_TESTING_FRAMEWORK_ACTIVE'] = '1'
        # Make sure that the MPS server is disabled before running the test-suite
        if utils.is_mps_server_running():
            print('DCGM Testing framework is not interoperable with MPS server. Please disable MPS server.')
            sys.exit(1)
        
        # Various setup steps
        option_parser.parse_options()
        utils.verify_user_file_permissions()
        utils.verify_localhost_dns()
        if not option_parser.options.use_running_hostengine:
            utils.verify_hostengine_port_is_usable()
        utils.verify_dcgm_service_not_active()
        if not test_utils.verify_dcgmi_executible_visible_for_all_users():
            print('DCGM Testing framework is located in the directory that is does have proper permissions to run ' \
                  'tests under unprivileged service account.')
            print('See the logs to understand which part of the path lacks the read+execute permissions')
            print('Either run `chmod o+rx <directory>` or move the DCGM Testing framework to another location')
            sys.exit(1)
        utils.verify_nvidia_fabricmanager_service_active_if_needed()

        if not test_utils.noLogging:
            logger.setup_environment()

            if logger.log_dir:
                logger.close()
            
        option_parser.validate()
        
        if not test_utils.is_framework_compatible():
            logger.fatal("The test framework and dcgm versions are incompatible. Exiting Test Framework.")
            sys.exit(1)

        # Directory where DCGM test*.py files reside
        test_utils.set_tests_directory('tests')

        # Verify that package architecture matches python architecture
        if utils.is_64bit():
            # ignore this check on ppc64le and armv8 for now
            if not (platform.machine() == "ppc64le" or platform.machine() == "aarch64"):
                if not os.path.exists(os.path.join(utils.script_dir, "apps/amd64")):
                    print("Testing package is missing 64bit binaries, are you sure you're using package of correct architecture?")
                    sys.exit(1)
        else:
            if not os.path.exists(os.path.join(utils.script_dir, "apps/x86")):
                print("Testing package is missing 32bit binaries, are you sure you're using package of correct architecture?")
                sys.exit(1)

        # Stops the framework if running python 32bits on 64 bits OS
        if utils.is_windows():
            if os.name == "nt" and "32 bit" in sys.version and platform.machine() == "AMD64":
                print("Running Python 32-bit on a 64-bit OS is not supported. Please install Python 64-bit")
                sys.exit(1)

        if utils.is_linux():
            python_exec = str(sys.executable)
            python_arch = check_output(["file", "-L", python_exec])

            if "32-bit" in python_arch.decode('utf-8') and utils.is_64bit() == True:
                print("Running Python 32-bit on a 64-bit OS is not supported. Please install Python 64-bit")
                sys.exit(1)

        #Tell DCGM how to find our testing package's NVVS
        test_utils.set_nvvs_bin_path()
Esempio n. 6
0
  .-'-.-'-.
 /         \\       ####   ####   #####  #   #  #####  ####   #   #
|           |      #   #  #   #  #      #   #  #      #   #  #   #
|   .-------'._    ####   ####   ###    # # #  ###    ####    # #
|  / /  '.' '. \\   #   #  #  #   #      # # #  #      #  #     #
|  \\ \\ @   @ / /   ####   #   #  #####   # #   #####  #   #    #
|   '---------'
|    _______|                       = 2015 =
|  .'-+-+-+|
|  '.-+-+-+|
|    """""" |
'-.__   __.-'
     """''')

    import eventloop
    import logger
    import leds

    logger.initialize(args)

    loop = eventloop.EventLoop(args.statemachine, args.webserver_port,
                               not args.disable_interbot)
    leds.initialize(loop)
    loop.start()
    logger.close()

    if args.pydev_debug:
        pydevd.stoptrace()

    sys.exit(loop.exit_value)
Esempio n. 7
0
def epilogue(cfg: Namespace, *varargs) -> None:
    logger.close()
Esempio n. 8
0
def main():
    global device
    global frame
    # put global options in the logger, since everything has access to it.
    logger.setOptions(config.options)

    # load all "plugin" modules.
    try:
        importTools(logger.options["plugin_dir"])
    except Exception as e:
        logger.log("Unable to import plugins:", e, logger.WARNING)
    print sys.path
    # make GUI
    app = wx.PySimpleApp()
    frame = NewGui(None)

    # setup propeller object
    device = Propeller.Device(
        nAnalogI,
        nAnalogO,
        nDigitals,
    )

    # define message handlers
    def versionHandler(propCom, ver):
        logger.log("Propeller version", ver, logger.INFO)
        device.queryChannel()

    def setHandler(propCom, cIdx, pVal):
        #if val is None:
        #	logger.log("bad request", "set", logger.ERROR)
        #else:
        try:
            #cIdx = val[0]
            #pVal = val[1]
            if cIdx not in device.channels:
                logger.log("invalid channel index", str(cIdx), logger.WARNING)
            else:
                logger.write(".")
                #device.channels[cIdx].
                #device.channels[cIdx].setValue(pVal)
                #frame.widgets[cIdx].setChan(device.channels[cIdx])
        except IndexError as e:
            logger.log("not enough values", "set", logger.ERROR)

    def startHandler(propCom, mask):
        #if val is None:
        #	logger.log("bad request", "start", logger.ERROR)
        #else:
        logger.log("started channels", mask, logger.INFO)
        #mask = val[0]
        for cIdx, chan in device.analogIn.iteritems():
            if not ((mask & (1 << chan.idx) > 0)
                    == chan.started):  # test if this channel is correct
                # not correct. correct the prop.
                logger.log("Channels dont match", chan.idx, logger.INFO)
                if chan.started:
                    chan.start()
                else:
                    chan.stop()
                propCom.send("start")

    def nchannelsHandler(propCom, nchans):
        """Start of dialog between propeller and PC"""
        global frame
        #if val is None:
        #	logger.log("bad request", "nChannel", logger.ERROR)
        #else:
        logger.log("nChannels", nchans, logger.INFO)
        # channels are added. register channels info functions
        #propCom.register("set", setHandler)
        propCom.register("start", startHandler)
        #propCom.register("dir", dirHandler)
        #propCom.register("d", digHandler)
        device.queryChannel()
        # prop state should now be setup. handle incoming data points.
        #propCom.register("p", pointHandler)
    def infoHandler(propCom, chanIdx, value, extra):
        device.channels[cIdx].setValue(value)
        if chanIdx < nAnalogI + nAnalogO:
            for cIdx, chan in device.analogIn.iteritems():
                if not ((mask & (1 << chan.idx) > 0)
                        == chan.started):  # test if this channel is correct
                    # not correct. adjust the UI
                    logger.log("Channels dont match", chan.idx, logger.INFO)
                    if chan.started:
                        chan.stop()
                    else:
                        chan.start()
                    device.queryChannel(chan.idx)
        elif chanIdx == nAnalogI + nAnalogO:
            pass  # this would be a pin dir map. not useful right now.

    def syncHandler(propCom, time, overflow=0):
        propCom.onSync(time)

    def dbgHandler(propCom, v1=None, v2=None, v3=None, v4=None, v5=None):
        strFmt = "Debug Message:\n"
        strFmt += str(v1) + "\n"
        strFmt += str(v2) + "\n"
        strFmt += str(v3) + "\n"
        strFmt += str(v4) + "\n"
        strFmt += str(v5) + "\n"
        logger.message(strFmt)

    #device.propCom.register("info", nchannelsHandler)
    device.propCom.register("version", versionHandler)
    if logger.options["debug_dialog"]:
        device.propCom.register("over", dbgHandler)
    device.propCom.register("sync", syncHandler)

    frame.createChannels(device)
    frame.Centre(wx.BOTH)

    device.propCom.start()  # start prop, begins polling open ports

    # setup complete, show frame.
    frame.Show()
    app.MainLoop()

    # program termination.
    device.propCom.close()
    logger.close()
Esempio n. 9
0
File: main.py Progetto: omertuc/DCGM
    def __enter__(self):
        '''Initialize the test framework or exit on failure'''

        os.environ['__DCGM_TESTING_FRAMEWORK_ACTIVE'] = '1'
        # Make sure that the MPS server is disabled before running the test-suite
        if utils.is_mps_server_running():
            print('DCGM Testing framework is not interoperable with MPS server. Please disable MPS server.')
            sys.exit(1)
        
        # Various setup steps
        option_parser.parse_options() 
        utils.verify_user_file_permissions()
        utils.verify_localhost_dns()
        if not option_parser.options.use_running_hostengine:
            utils.verify_hostengine_port_is_usable()

        if not test_utils.noLogging:
            logger.setup_environment()

            if logger.log_dir:
                logger.close()
            
        option_parser.validate()
        
        if not test_utils.is_framework_compatible():
            logger.fatal("The test framework and dcgm versions are incompatible. Exiting Test Framework.")
            sys.exit(1)

        # Directory where DCGM test*.py files reside
        test_utils.set_tests_directory('tests')

        # Verify that package architecture matches python architecture
        if utils.is_64bit():
            # ignore this check on ppc64le and armv8 for now
            if not (platform.machine() == "ppc64le" or platform.machine() == "aarch64"):
                if not os.path.exists(os.path.join(utils.script_dir, "apps/amd64")):
                    print("Testing package is missing 64bit binaries, are you sure you're using package of correct architecture?")
                    sys.exit(1)
        else:
            if not os.path.exists(os.path.join(utils.script_dir, "apps/x86")):
                print("Testing package is missing 32bit binaries, are you sure you're using package of correct architecture?")
                sys.exit(1)

        # Stops the framework if running python 32bits on 64 bits OS
        if utils.is_windows():
            if os.name == "nt" and "32 bit" in sys.version and platform.machine() == "AMD64":
                print("Running Python 32-bit on a 64-bit OS is not supported. Please install Python 64-bit")
                sys.exit(1)

        if utils.is_linux():
            python_exec = str(sys.executable)
            python_arch = check_output(["file", "-L", python_exec])

            if "32-bit" in python_arch and utils.is_64bit() == True:
                print("Running Python 32-bit on a 64-bit OS is not supported. Please install Python 64-bit")
                sys.exit(1)

        #Tell DCGM how to find our testing package's NVVS
        if not os.path.isfile('./apps/nvvs/nvvs'):
            logger.warning("NVVS is missing from the test framework install. Hopefully it's installed.")
        else:
            nvvsDir = os.getcwd() + '/apps/nvvs'
            logger.debug("NVVS directory: %s" % nvvsDir)
            os.environ['NVVS_BIN_PATH'] = nvvsDir #The env variable parser in DcgmDiagManager is only the directory
Esempio n. 10
0
def main():
    lg.log_start()
    options = ["Create CSV File", "View files", "Graphing", "Modelling", "Calculate"]

    print("--ComPhys--")
    for i in range(len(options)):
        optNum = "[" + str(i + 1) + "]"
        print(optNum + " " + options[i])

    selection = int(input("Selection:")) - 1

    # Creating a CSV file by entering data points manually
    if selection == 0:
        lg.log("Displaying CSV file creation options")
        print("\n--Create CSV File--\n")
        newfilename = input("Please enter file name:")
        createdfile = fio.createfile(newfilename)

        print("Enter values as x,y pairs. Ex: 4,5")  # Instructions for the user
        print("Enter z when finished.")

        addvals = True
        while addvals:  # A while loop that takes data points from the user and writes them to the file
            newval = input("Enter data: ")

            if newval == "z":
                addvals = False
                print("File saved.")
            else:
                createdfile.write(newval + "\n")

        lg.log("New CSV file " + newfilename + " created and saved")

    # Viewing a file in the working directory
    elif selection == 1:
        lg.log("Displaying files in directory")
        print("\n--Files in Directory--\n")
        file_list = listdir('data')
        for i in range(len(file_list)):
            print(("[" + str(i + 1) + "]" + "\t" + file_list[i]))

        selection = int(input("Selection:")) - 1

        with open("data/" + file_list[selection]) as file:
            for line in file:
                print(line)

    # Graphing
    # TODO: Currently set up for testing, needs to be modified for general use
    elif selection == 2:
        lg.log("Displaying graphing options")
        print("\n--Graphing Options--\n")
        print("[1] Line Chart (Default)")

        selection = int(input("Selection:")) - 1

        xvals = []
        yvals = []

        with open("data/testdata.csv") as file:
            for line in file:
                vals = line.split(",")
                xvals.append(vals[0])
                yvals.append(vals[1])

        # if selection == 1:

        graphing.plot.defaultchart("TEST CHART", "TEST_X", "TEST_Y", xvals, yvals)

    # Physical Modelling
    elif selection == 3:
        lg.log("Displaying modelling options")
        print("\n--Modelling Options--\n")
        print("[1] Projectile Motion Trajectory (2D)")


    # Calculation Options
    elif selection == 4:
        lg.log("Displaying calculation options")
        print("\n--Calculation Options--\n")

    # Steps taken at the end of the program- printing a closing line and ending the log
    print("~~~~~~~~~~~~~End of Program~~~~~~~~~~~~~")
    lg.close()
Esempio n. 11
0
 def close(self):
     self.set_state(gst.STATE_NULL)
     self.log()
     logger.close()