Viscosity is an essential transport property in gas dynamics, especially the bulk viscosity, which exhibits more complex behavior. Carbon monoxide (CO) is a molecule of weak polarity, which exists in many important fields such as combustion and coke metallurgy. In order to effectively uncover the mechanism of the CO viscosity, this study dealt with it from a microscopic view. A transcale model is built which integrates density functional theory (DFT, first-principles) calculations with equilibrium molecular dynamics (EMD) simulations to establish a microscale foundation. Based on that, a fitted high-precision potential function is formed, then by using the Green-Kubo linear response theory, the shear and bulk viscosities of CO are achieved in a medium temperature range of 100–800 K. The MD simulation is implemented with C programming language, and an adaptive time-step algorithm is applied so that the computational efficiency is significantly enhanced. The resulting bulk viscosity exhibits quite obvious sensitivity to the potential function of the molecule system, while the shear viscosity shows little. Unlike the shear viscosity, which appears more linear, the bulk viscosity shows clear nonlinear behavior that changes with temperature. Correspondingly, traditional theoretic models and experimental results from different literature indicate that the bulk viscosity at medium temperatures is overestimated to various degrees. Fitting functions on the shear and bulk viscosities in the defined temperature range are established, respectively. Additionally, the lower system pressure and larger system size in the model effectively reduce statistical pressure fluctuations and improve the convergence of relevant laws. This work elucidates the microscopic mechanism of CO viscosity and provides a high-fidelity theoretical tool for modeling the viscosity of high-temperature nonequilibrium gas flows (e.g. hypersonic boundary layers, and plasma transport).